Skip to content
We areTOP 1%

Digital Logarithm

MediumRating 1400CodeforcesHeap / Priority Queue
Solve on Codeforces(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Approach hintTry it first, then reveal

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.

More in Heap / Priority Queue

Heap / Priority Queue questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Last Stone WeightLeetCodeEasy Solve Last Stone Weight on LeetCode (opens in a new tab)
2Kth Largest Element in a StreamLeetCodeEasy Solve Kth Largest Element in a Stream on LeetCode (opens in a new tab)
3Powering the Hero (hard version)CodeforcesEasy 1100Solve Powering the Hero (hard version) on Codeforces (opens in a new tab)
4Kth Largest Element in an ArrayLeetCodeMedium Solve Kth Largest Element in an Array on LeetCode (opens in a new tab)
5K Closest Points to OriginLeetCodeMedium Solve K Closest Points to Origin on LeetCode (opens in a new tab)
6Task SchedulerLeetCodeMedium Solve Task Scheduler on LeetCode (opens in a new tab)
7Phoenix and TowersCodeforcesMedium 1400Solve Phoenix and Towers on Codeforces (opens in a new tab)
8Productive MeetingCodeforcesMedium 1400Solve Productive Meeting on Codeforces (opens in a new tab)
9Digital LogarithmCodeforcesMedium 1400Solve Digital Logarithm on Codeforces (opens in a new tab)
10Potions (Easy Version)CodeforcesMedium 1500Solve Potions (Easy Version) on Codeforces (opens in a new tab)
11Lunar New Year and a WanderCodeforcesMedium 1500Solve Lunar New Year and a Wander on Codeforces (opens in a new tab)
12Merge k Sorted ListsLeetCodeHard Solve Merge k Sorted Lists on LeetCode (opens in a new tab)
13Find Median from Data StreamLeetCodeHard Solve Find Median from Data Stream on LeetCode (opens in a new tab)

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account