Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is not found in the array, return [-1, -1]. Example 1: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4] Example 2: Input: nums = [5,7,7,8,8,10], … Continue reading Find First and Last Position of Element in Sorted Array

# Category: Binary Search Algorithm

## First Bad Version

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have n versions [1, 2, ..., n] and you want to … Continue reading First Bad Version

## Convert Sorted Array to Binary Search Tree

Hi Geeks! Welcome to 100 Days of Leetcode Challenge. In this article, we going to see about how to Convert Sorted Array to Binary Search Tree. Day 45 of 100 Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined … Continue reading Convert Sorted Array to Binary Search Tree

## Binary Search – Best Explanation

Hi Geeks! Today, we going to see about Binary Search Algorithm to search an element in an array. When an array is sorted, we can apply the binary search algorithm. There are two ways to search an element in an array. Linear SearchBinary Search Linear Search When an array is unsorted, we can apply the … Continue reading Binary Search – Best Explanation