July 13, 2019 by Sandeep Bhardwaj | Tags: Leetcode Datastructure & Algorithms
Find First and Last Position of Element in Sorted Array /** * 34. Find First and Last Position of Element in Sorted Array * <p> * Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. * <p> * Your algorithm's ru...
Read moreJuly 12, 2019 by Sandeep Bhardwaj | Tags: Leetcode Datastructure & Algorithms
Find Minimum in Rotated Sorted Array /** * 153. Find Minimum in Rotated Sorted Array * <p> * Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. * <p> * (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). * <p> * Find the mi...
Read moreJuly 11, 2019 by Sandeep Bhardwaj | Tags: Leetcode Datastructure & Algorithms
Remove Linked List Elements /** * 203. Remove Linked List Elements * Remove all elements from a linked list of integers that have value val. * <p> * Example: * <p> * Input: 1->2->6->3->4->5->6, val = 6 * Output: 1->2->3->4->5 */ public class Rem...
Read moreJuly 10, 2019 by Sandeep Bhardwaj | Tags: Leetcode Datastructure & Algorithms
Remove Duplicates from Sorted List /** * 83. Remove Duplicates from Sorted List * <p> * Given a sorted linked list, delete all duplicates such that each element appear only once. * <p> * Example 1: * <p> * Input: 1->1->2 * Output: 1->2 * Example 2: * <p>...
Read moreJuly 09, 2019 by Sandeep Bhardwaj | Tags: Leetcode Datastructure & Algorithms
Container With Most Water Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the conta...
Read more