Skip to content

Practice Sort Integers by The Power Value

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1387
LeetCode Problem

Sort Integers by The Power Value

Problem Statement

The power of x is the number of operations needed to reach 1: replace an even x with x / 2, and an odd x with 3 * x + 1. Sort the integers in the inclusive interval [lo, hi] by increasing power, breaking ties by increasing integer value. Return the kth value in this order, with k counted from 1. Every input value is guaranteed to reach 1, and its power fits in a 32-bit signed integer.

Source: Sort Integers by The Power Value on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
lo = 12, hi = 15, k = 2
Output
13

# Example 2

Input
lo = 7, hi = 11, k = 4
Output
7

Constraints

1 <= lo <= hi <= 1000
1 <= k <= hi - lo + 1

Related LeetCode Problems

Practice more problems similar to Sort Integers by The Power Value.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.