You have a list arr of all integers in the range [1, n] sorted in a strictly increasing order. Apply the following algorithm on arr:
Given the integer n, return the last number that remains in arr.
Example 1:
Input: n = 9 Output: 6 Explanation: arr = [1, 2, 3, 4, 5, 6, 7, 8, 9] arr = [2, 4, 6, 8] arr = [2, 6] arr = [6]
Example 2:
Input: n = 1 Output: 1
Constraints:
1 <= n <= 109Solutions for this problem are being prepared.
Try solving it yourself❌ Don't Run Behind 500 LEETCODE Problems ❌ Focus on QPCD • Striver • 522,243 views views
Watch 9 more video solutions →Practice Elimination Game with our built-in code editor and test cases.
Practice on FleetCode