Binary Search with Boundary Conditions

Implement binary search: given a non-decreasing array nums and an integer x, return the first occurrence index (lowest index) of x. Return -1 if x does not exist.

Requirements:

  • Ti...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: