Question: Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
example1: input num=[1,3,5,6,7,13,21,27]=21
output: 6
example2: input num=[1,4,5,7,14,17,21,28]=17
output: 5
example2: input num=[2,3,5,7,13,19,24,27]=27
output:7
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
