Digital Logarithm
MediumRating 1400CodeforcesHeap / Priority Queue
Approach hintTry it first, then revealHide
Compare the largest remaining elements of both arrays using two max-heaps. Equal tops cancel; otherwise replace the larger one by its number of digits and count one operation. Values shrink quickly, so this terminates fast.