Interview Questions

Find Minimum in Rotated Sorted Array

Leetcode#153 Find Minimum in Rotated Sorted Array Logic Please read normal Binary search code for finding target and its comparison with rotated array. This will help to build foundation. Problem Statement Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: Notice that rotating an array [a[0], a[1], a[2], …, a[n-1]] 1 time […]

prakashsinghabody@gmail.com 
Interview Questions

Delete the Middle Node of a Linked List

Leetcode#2095 Delete the Middle Node of a Linked List Problem Statement You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list. The middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing, where ⌊x⌋ denotes the largest integer less than or equal to x. Example 1: Input: head = [1,3,4,7,1,2,6] Output: [1,3,4,1,2,6] […]

prakashsinghabody@gmail.com 
Interview Questions

Container With Most Water

Leetcode#11 Container With Most Water Problem Statement 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 […]

prakashsinghabody@gmail.com 
Interview Questions

Minimum Number of Arrows to Burst Balloons

Leetcode#452 Minimum Number of Arrows to Burst Balloons Problem Statement There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points[i] = [xstart, xend] denotes a balloon whose horizontal diameter stretches between xstart and xend. You do not know the exact y-coordinates of the balloons. Arrows can be shot […]

prakashsinghabody@gmail.com 
Interview Questions

Longest Substring Without Repeating Characters

Leetcode#3 Longest Substring Without Repeating Characters Problem Statement Given a string s, find the length of the longest  substring  without repeating characters. Example 1: Input: s = “abcabcbb” Output: 3 Explanation: The answer is “abc”, with the length of 3. Example 2: Input: s = “bbbbb” Output: 1 Explanation: The answer is “b”, with the length of […]

prakashsinghabody@gmail.com 
Interview Questions

(TBD)Longest Consecutive Sequence

Leetcode#128 Longest Consecutive Sequence Problem Statement Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n) time. Example 1: Input: nums = [100,4,200,1,3,2] Output: 4 Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4. Example 2: Input: […]

prakashsinghabody@gmail.com