Insert Position

Let's solve one basic problem and test our approach. Difficulty Level: Easy

Problem statement

We are given a sorted array of distinct integers and a target value. We will return the index if the target is found. Otherwise, we will return the index to where it would be if it were inserted in order.

Constraints:

  • 1nums.length1031 \leq nums.length \leq 10^3
  • 103nums[i]103-10^3 \leq nums[i] \leq 10^3
  • numsnums contains distinct values, sorted in ascending order.
  • 103target103-10^3 \leq target \leq 10^3
...