...

/

First Element Equals its Index

First Element Equals its Index

Let's check another problem with a sorted input array. Difficulty Level: Easy

Problem statement

Suppose we are given a sorted array of distinct integers, nums, which are sorted in ascending order. We will return the smallest index i, which satisfies nums[i] == i. If no such i exists, we will return -1.

Constraints:

  • 1nums.length1031 \leq nums.length \leq 10^3
...