Day 17 Problem

Hello and welcome back brave human being,

Now that we have learned about the basics of binary search you‘ll start seeing this pattern, ✨ everywhere ✨ .

Today’s problem is going to help you understand how can binary search be incorporated into a problem.

Given a sorted array of distinct integers and a target value, return the index if the target is found. If not found, return the index where it would be if it were inserted in order.

Let's set an example…

Input: nums = [1,3,5,6], 

target = 5

Output: 2

What is the time complexity of a binary search?

Login or Subscribe to participate in polls.

Remember: LeetCode problem a day keeps unemployment away!

Cheers to your success,

Denisse

Reply

or to participate.