Search
⌘K
Get Premium
Leetcode 1387. Sort Integers by The Power Value
Compute each integer's Collatz "power" (number of steps to reach 1 using x/2 for even and 3x+1 for odd), sort the numbers in [lo, hi] by power (breaking ties by numeric value), and return the k-th element in that order. The range is small (hi ≤ 1000), so precomputing powers for the interval is sufficient.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.