cs.thefarshad
easy Binary Search

Search Insert Position

Given a sorted array `nums` of distinct integers and a `target`, return the index if it is found. If not, return the index where it would be inserted to keep the array sorted. Example: ([1, 3, 5, 6], 5) → 2; ([1, 3, 5, 6], 2) → 1; ([1, 3, 5, 6], 7) → 4.

runs in your browser