1064. Fixed Point
https://leetcode.com/problems/fixed-point
Description
Given an array of distinct integers arr
, where arr
is sorted in ascending order, return the smallest index i
that satisfies arr[i] == i
. If there is no such index, return -1
.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= arr.length < 104
-109 <= arr[i] <= 109
Follow up: The O(n)
solution is very straightforward. Can we do better?
ac
Last updated