coding

Find First and Last Position of Element in Sorted Array

Description Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n) runtime complexity. Solution Performance Explanation  By the description we know that the solution has to be, O(log n) this hit us that we must …

Find First and Last Position of Element in Sorted Array Read More »

Container With Most Water

Description You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that together with the x-axis form a container, such that the container contains the most water. Return the maximum amount of water a container can store. Explanation To calculate the area …

Container With Most Water Read More »