Practice Elimination Game
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Start with the ordered list 1 through n. On the first pass, move left to right, removing the first value and every other value afterward. On the next pass, move right to left, removing the rightmost remaining value and then every other value. Alternate directions with the same rule until one value remains, and return it.
Source: Elimination Game on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 9
Output
6
# Example 2
Input
n = 1
Output
1
Constraints
1 <= n <= 10^9
Related LeetCode Problems
Practice more problems similar to Elimination Game.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.