Given a sorted array of distinct integers `values` and a target integer `target`, find the index of the first element in `values` that is strictly greater than `target`. If no such element exists, return -1.
Explanation: Find the index of the first element strictly greater than 15. The elements greater than 15 are 16, 23, 38, 56, 72, 91. The first of these is 16, which is at index 4.
Explanation: Find the index of the first element strictly greater than 50. There is no element in the array strictly greater than 50. Thus, the output is -1.
Explanation: Find the index of the first element strictly greater than 3. The first element, 5, is greater than 3. Thus, the index is 0.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak