Tap here to switch tabs
Problem
Submissions

Problem: Sort Integers by The Power Value

Try to solve the Sort Integers by The Power Value problem.

Statement

The power of an integer xx is defined as the number of steps required to transform xx into 11 by repeatedly applying the following operations:

  • If xx is even, then x=x/2x = x / 2

  • If xx is odd, then x=3imesx+1x = 3 imes x + 1

Given three integers lo, hi, and k, sort all integers in the inclusive range [[lo, hi]] in ascending order based on their power value. If two or more integers have identical power values, sort them in ascending numerical order.

Return the kk-th integer (11 indexed) in the sorted range.

Constraints:

  • 1≤1 \leq lo ≤\leq hi ≤1000\leq 1000

  • 1≤1 \leq k ≤\leq hi −- lo +1+ 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sort Integers by The Power Value

Try to solve the Sort Integers by The Power Value problem.

Statement

The power of an integer xx is defined as the number of steps required to transform xx into 11 by repeatedly applying the following operations:

  • If xx is even, then x=x/2x = x / 2

  • If xx is odd, then x=3imesx+1x = 3 imes x + 1

Given three integers lo, hi, and k, sort all integers in the inclusive range [[lo, hi]] in ascending order based on their power value. If two or more integers have identical power values, sort them in ascending numerical order.

Return the kk-th integer (11 indexed) in the sorted range.

Constraints:

  • 1≤1 \leq lo ≤\leq hi ≤1000\leq 1000

  • 1≤1 \leq k ≤\leq hi −- lo +1+ 1