Container With Most Water LeetCode Solution


Frequently asked in Adobe Amazon Apple Arcesium Bloomberg ByteDance Flipkart Google Intel Intuit JP Morgan Microsoft Oracle Qualtrics Salesforce Samsung SAP Swiggy Tesla Uber VMware Yahoo
categories - Medium tiktok Walmart Wix ZomatoViews 3

Problem Statement

Container With Most Water LeetCode Solution says that – You are given an integer array height of length n. There are n vertical lines are 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.

Notice that you may not slant the container.

 

Example 1:

Container With Most Water LeetCode SolutionPin

 Input : 
  
  height = [1,8,6,2,5,4,8,3,7]

Output:

 49

Explanation:

 The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.

Example 2:

Input:

 height = [1,1]

Output:

 1

Constraints:

  • n == height.length
  • 2 <= n <= 105
  • 0 <= height[i] <= 104

ALGORITHM –

IDEA –

  • In order to find Container With Most Water. We will Focus on the maximum area covered between two vertical lines representing the maximum amount of water contained by the container.
  • So our final answer will be (height between two vertical * distance between them). so what we will do first we will take two pointers one pointer start from 0 and another from last and we will compare the height and  the height which will be smaller we will take that height and multiply distance between both the heights.
  • After that if height[i] > height[j] then decrease the pointer from last and if height[i] < height[j] then increase the pointer i by 1 and update res with maximum and at last we will return a maximum one.

APPROACH –

  • First we will make two pointer i = 0,j = length of array and one variable res = 0.
  • After that, we will traverse the array and check for the condition if height[i] > height[j] then calculate the area and update res.
  • Then Decrement in j by 1 else same condition will happen instead of decrement we will increase the i by 1 and return res.
  • Hence, Container With Most Water will be calculated.

Image of Container With Most Water LeetCode Solution –

Container With Most Water LeetCode SolutionPinContainer With Most Water LeetCode SolutionPin Container With Most Water LeetCode SolutionPin

class Solution {
    public int maxArea(int[] height) {
        
        int i = 0;
        int j = height.length-1;
        int res = 0;
        
        while(i < j){
            
            if(height[i] > height[j]){
                
                res = Math.max(res,Math.min(height[i],height[j])*(j-i));
                j-=1;
                    
            }
            else{
                res = Math.max(res,Math.min(height[i],height[j])*(j-i));
                i+=1;
                
            }
            
        }    
        return res;         
        
        
    }
}
class Solution:
    def maxArea(self, height: List[int]) -> int:
        
        i = 0
        j = len(height)-1
        res = 0
        
        while(i < j):
            
            if height[i] > height[j]:
                res = max(res,min(height[i],height[j])*(j-i))
                
                j-=1
                
            else:
                res = max(res,min(height[i],height[j])*(j-i))
                i += 1
                
        return res

Time Complexity: O(N), As we have traversed the whole array only once.

Space Complexity: O(1), As we have not taken any Extra Space.

SIMILAR QUESTION – https://www.tutorialcup.com/leetcode-solutions/water-bottles-leetcode-solution.htm

 

 

 

Top Interview Questions

S.No Interview Question Number of times has been asked
1Delete a node in doubly linked list2831
2Java program to find the number of Nodes in a Binary Tree2510
3Reverse a string without affecting special characters2470
4Delete a node of a linked list at given position1984
5Palindrome using Recursion1884
6Insert nodes in a linked list in a sorted way (Ascending Order)1669
7Find elements pair from array whose sum equal to number1655
8Sort Elements by Frequency of Occurrences1643
9Quick Sort1627
10Write a program to print all permutations of a given string1615
11Find Minimum Distance Between Two Numbers in an Array1480
12Create a Doubly Linked List1456
13Reverse an Array1417
14Smallest window in a string containing all characters of another string1402
15Find a Triplet That Sum to a Given Value1366
16Recursively remove all adjacent duplicates1363
17First Repeating Element1346
18Arrange Even and Odd number such that Odd comes after Even1328
19Sum of numbers in String1325
20Smallest Positive Number Missing in an Unsorted Array1293
21Check if the Elements of an Array are Consecutive1262
22Detect a loop in the Linked List1247
23Largest Sum Contiguous Subarray1235
24Quick Sort on SIngly Linked List1226
25Subarray with Given Sum1217
26Print all Possible Combinations of R Elements in a given Array of size N1212
27Recursive function to do substring search1208
28Find the Maximum Repeating Number in Array1161
29Binary Tree Level order traversal in Java1132
30Find the First and Second Smallest Elements1126
31Check if two linked lists are identical1113
32Maximum Subarray Sum using Divide and Conquer1111
33Remove characters from first string which are in second1077
34Find Leaders in an Array1066
35Swap nodes in the linked list1044
36Find the Number Occurring Odd Number of Times in an Array1009
37Arrange given Numbers to Form the Biggest Number II999
38Find the second most frequent character998
39Given a string find its first non-repeating character977
40Find Triplet in Array With a Given Sum969
41Total number of occurrences of a given item in the linked list960
42Given a sorted array and a number x, find the pair in array whose sum is closest to x959
43A Program to check if strings are rotations of each other or not958
44Print all possible words from phone digits940
45Find the Missing Number932
46Rearrange Positive and Negative Numbers Alternatively in Array928
47Longest Palindromic Substring911
48Segregate even and odd nodes in a linked list895
49Print Longest common subsequence891
50Union and Intersection of Two Linked Lists880
51Transform one string to another using minimum number of given operations875
52Check rearranged string can form a palindrome857
53Rearrange given Array in Maximum Minimum Form852
54Iterative Implementation of Quick Sort841
55Count Possible Triangles829
56Multiplication of Two Matrices811
57Check if the linked list is palindrome803
58Count of Triplets With Sum Less than Given Value802
59Rotate a Linked List802
60Stock Buy Sell to Maximize Profit797
61Insertion Sort773
62Concatenation of two strings769
63Tug of War767
64Count Number of Substrings with K Distinct Character’s764
65Print all duplicates in the input string762
66Find Nearest Greater and Smaller Element751
67The Celebrity Problem745
68Find Pythagorean Triplets from Array744
69Reverse String Without Temporary Variable739
70Remove ‘b’ and ‘ac’ from a given string739
71Find all Common Elements in Given Three Sorted Arrays735
72Remove all duplicates in an unsorted linked list717
73Find the Row with Maximum Number of 1’s712
74Find the Peak Element from an Array707
75Find the subarray whose sum is equal to a given number X705
76Remove Minimum Characters so that Two Strings Become Anagrams698
77Addition of Two Matrices693
78Find Smallest Missing Number in a Sorted Array691
79A Product Array Puzzle689
80Generate all Binary Strings Without Consecutive 1’s686
81Implement Two Stacks in an Array682
82Maximum Sum of Non Consecutive Elements679
83Maximum Product Subarray II665
84Lexicographic rank of string662
85Check if Two given Matrices are Identical655
86Multiplication of Previous and Next653
87Subtraction of Two Matrices644
88Merge K Sorted Arrays and Print Sorted Output639
89Move All the Zeros to the End of the Given Array638
90Divide a string in N equal parts634
91Online Algorithm for Checking Palindrome in a Stream629
92Form Minimum Number from Given Sequence of D’s and I’s629
93Check whether two strings are anagram of each other624
94Remove recurring digits in a given number622
95Sort a linked list that is sorted alternating ascending and descending617
96Maximum Circular Subarray Sum617
97Sort a stack using a temporary stack615
98Find the Minimum Element in a Sorted and Rotated Array611
99Move last element of the Linked List at first place610
100Subarray and Subsequence607
101First Circular Tour to Visit all the Petrol Bunks605
102Largest Subarray with Equal Number of 0’s and 1’s602
103Compare two strings(linked lists)601
104Flattening a linked list600
105Maximum Element in an Array which is Increasing and then Decreasing599
106Palindrome Permutations of a String595
107Elements Appear more than N/K times in Array588
108Palindromes in a given range585
109Run length encoding584
110Majority Element584
111Print all permutations with repetition583
112Pangram Checking581
113Minimum insertions to form a shortest palindrome581
114Minimum Characters to be Added at Front to Make String Palindrome573
115Rearrange a given linked list in-place572
116Remove all duplicates in a sorted linked list571
117Merge a linked list into another at alternate positions571
118Most repeating character in a string569
119Rotate string to get lexicographically minimum string569
120Minimum number of Merge Operations to make an Array Palindrome568
121Repeated Subsequence of Length Two or More566
122Print all anagrams together in a sequence of words561
123Reorder an Array According to the Given Indexes557
124Pancake Sorting Problem548
125Two Sum Leetcode Solution546
126Merge Overlapping Intervals II546
127Clone a Linked List with next and random pointer544
1283Sum Leetcode Solution543
129Size of The Subarray With Maximum Sum534
130Transpose of a Matrix533
131Remove Extra Spaces from a String530
132Removing Spaces from a String using stringstream529
133Partition Problem527
134Remove duplicates from a string527
135Check if a given string is a rotation of a palindrome526
136Longest Palindrome can be Formed by Removing or Rearranging Characters525
137Maximum Sum Increasing Subsequence524
138Smallest Palindrome after Replacement524
139Generate all Binary Strings from Given Pattern515
140Check whether Strings are K Distance Apart or Not515
141Length of Longest valid Substring510
142Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized509
143Insert Node in the Sorted Linked List507
144Delete Last Occurrence506
145Check if Two given Strings are Isomorphic to each other502
146Maximum difference between two elements such as larger element comes after smaller495
147Program to Toggle all Characters in a String493
148Given string is interleaving of two other strings or not491
149Count Minimum Steps to Get the given Array487
150Merge sort better than quick sort for linked lists484
151Number of Smaller Elements on Right Side483
152Check length of a String is Equal to the Number Appended at its Last481
153Find Pair with Given Difference480
154Check if all Rows of a Matrix are Circular Rotations of Each Other480
155Longest Common Prefix using Divide and Conquer477
156Find nth node of the Linked list from the end477
157Print all interleavings of given two strings468
158Find a Fixed Point in a Given Array468
159Sort 0s 1s and 2s in an Array468
160Compare Two Version Numbers465
161Merge two sorted linked lists such that merged list is in reverse order462
162Reverse words in a given string462
163Reorder Array Using Given Indexes461
164Find the Subarray of given length with Least Average461
165Print Reverse of a string (Recursion)460
166Median of Two Sorted Arrays LeetCode Solution459
167Split linked list using alternate nodes459
168Print string of odd length in ‘X’ format445
169Print all Palindromic Partitions of a String441
170Swap Kth Node from beginning with Kth Node from End441
171Find K Length Subarray of Maximum Average441
172Find Element Using Binary Search in Sorted Array440
173Find Duplicates in an Array in Most Efficient Way433
174print all palindromic partitions427
175Flatten a multilevel linked list424
176Shortest Superstring Problem424
177Maximum Length of Chain Pairs423
178Check if String Follows Order of Characters by a Pattern or not420
179Sorting a K Sorted Array418
180Sort a String According to Another String413
181Longest Span with same Sum in two Binary Arrays II404
182Reverse a Linked List in groups402
183Find a Sorted Subsequence of size 3401
184Recursively print all the sentences that can be formed from list of word lists399
185Program to add two binary digits398
186Longest Common Prefix Using Binary Search II396
187Reverse a Singly Linked List (Iterative/Non-Recursive)394
188Find the two Numbers with Odd Occurrences in an Unsorted Array394
189Caesar Cipher390
190Kth Non-repeating Character389
191Rearrange a linked list in Zig-Zag386
192Check if String can Become Empty by Recursively Deleting given Substring385
193Longest Common Prefix Word by Word Matching382
194Pancake Sorting381
195Rotate Image by 90 degrees380
196Permutations of a Given String Using STL373
197Perfect Reversible String372
198Merging Two Sorted Arrays370
199Increasing Subsequence of Length three with Maximum Product368
2001`s and 2`s complement of binary number367
201Sort a linked list with 0s, 1s and 2s367
202Find First non-repeating character in a string366
203Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes366
204Find the point where a monotonically increasing function becomes positive first time366
205Four Elements that Sum to Given363
206List items containing all characters of a given word361
207Delete N nodes after M360
208Longest Common Prefix using Character by Character Matching357
209Count Number of Occurrences in a Sorted Array354
210Palindrome string (number)351
211Split a string349
212Minimum Characters to be Removed to Make a Binary String Alternate344
213Recursive Implementation of atoi()342
214Check if a Linked list of Strings form a Palindrome341
215Sorting the array of strings339
216Print All Distinct Elements of the Array339
217Maximum occurring character in a string337
218Even Substring Count336
219Convert a String that is Repetition of a Substring of Length K336
220Valid Parentheses LeetCode Solution335
221Reverse a singly linked list recursively334
222Find the first Repeating Number in a Given Array334
223Print Shortest Path to Print a String on Screen331
224Can we reverse a linked list in less than O(n) time ?331
225Convert string1 to string2 in one edit330
226Binary Tree to Doubly linked list329
227Nth Character in Concatenated Decimal String328
228Reverse a String using Stack326
229wildcard character matching326
230Sort Elements by Frequency II325
231Lower Case To Upper Case324
232Maximum Subarray Leetcode Solution324
233Merge Two Sorted Arrays319
234Count the number of words318
235Split Four Distinct Strings317
236Find the Lost Element From a Duplicated Array315
237Find middle of the Linked List313
238Matrix Chain Multiplication using Dynamic Programming309
239Longest Common Subsequence with Permutations309
240Count the Pairs at Same Distance as in English Alphabets309
241Next Greater Element in an Array303
242Palindrome Permutation299
243Roman to Integer Leetcode Solution293
244Find Nth Node293
245Searching a node in a Binary Search Tree291
246Find All Pairs With a Given Difference290
247Triplet from three linked lists with given sum286
248Delete a Tree286
249String(represents an integer) to value285
250Reverse a String284
251Word Search Leetcode Solution283
252Reverse Bits282
253Delete a node under given conditions282
254Print all Possible Ways to Break a String in Bracket Form281
255Change Gender of a given String279
256Binary Tree279
257How to Efficiently Implement k Stacks in a Single Array?277
258Sort an array of strings277
259Toeplitz Matrix276
260Count Pairs With Given Sum275
261First non Repeating Element274
262Number of sub-strings which recursively add up to 9273
263Meeting Rooms II LeetCode Solution273
264Repeated Substring Pattern272
265Longest Common Extension271
266Remove middle points in a linked list of line segments271
267N queen problem271
268Move all negative elements to one side of array270
269Remove spaces from a string268
270Longest Palindromic Substring LeetCode Solution266
271Min Stack264
272Shuffle a given Array264
273Dijkstra Algorithm261
274Number of Islands LeetCode Solution260
275Cuckoo sequence program259
276Find, second, frequent, character258
277House Robber Leetcode Solution258
278Max stack258
279Fibonacci numbers257
280Most Frequent Element in an Array256
281Minimize the maximum difference between the heights255
282Clone a linked list with next and random pointer (Hashing)253
283Search Insert Position Leetcode Solution253
284Expression Evaluation252
285Sort linked which is sorted on absolute values250
286KMP Algorithm250
287Sudoku Solver249
288Subset Leetcode249
289Valid Palindrome Leetcode Solution248
290Word Search247
291Plus One Leetcode Solution247
292Number Of 1 bits246
293Reverse words in a string246
294Evaluation of Postfix Expression246
295How to Delete a Linked List245
296Combination Sum Leetcode Solution245
297Min Stack Leetcode Solution244
298Backspace String Compare241
299Set Matrix Zeroes238
300Rabin Karp Algorithm237
301Pair of Positive Negative Values in an Array237
302Sqrt(x) Leetcode Solution237
303Merge Sorted Arrays Leetcode Solution236
304Reversing a Queue236
305Subarray with 0 sum234
306Tower Of Hanoi233
307Common elements in all rows of a given matrix233
308Combination Sum231
309Delete middle element of a stack230
310Product of array except self230
311Integer to Roman Leetcode Solution230
312Contains Duplicate II Leetcode Solution230
313Pascal Triangle Leetcode229
314String Compression228
315Intersection of Two Arrays II Leetcode Solution228
316Minimum swaps required to bring all elements less than or equal to k together227
317Reverse individual words227
318Segregate even and odd numbers226
319Construct Binary Tree from Given Inorder and Preorder Traversals225
320Find Top K (or Most Frequent) Numbers in a Stream225
321Count subarrays with equal number of 1’s and 0’s225
322Count of index pairs with equal elements in an array225
323Implementation of Deque using Doubly Linked List224
324Bellman Ford Algorithm224
325Sliding Window Technique224
326Add Binary Leetcode Solution224
327Contains Duplicate223
328Count Odd Numbers in an Interval Range Leetcode Solution223
329Single Number Leetcode Solution223
330Minimum Value to Get Positive Step by Step Sum Leetcode Solution223
331Arithmetic Expression Evaluation222
332Find sum of non-repeating elements (distinct) elements in an array222
333Second Most Repeated Word in a Sequence221
334Postfix to Infix Conversion221
335Sort elements by frequency221
336Palindrome Linked List Leetcode Solution221
337Pow(x, n) Leetcode Solution220
338Maximum Number of Balloons Leetcode Solution219
339Page Replacement Algorithms in Operating Systems219
340Kruskal Algorithm218
341Next Permutation218
342Design a stack that supports getMin() in O(1) time and O(1) extra space218
343Group Words With Same Set of Characters218
344K-th Smallest Element in a Sorted Matrix216
345Longest Common Prefix Leetcode Solution216
346Smallest Subarray with k Distinct Numbers216
347Sum of minimum and maximum elements of all subarrays of size k216
348Scramble String216
349Third Maximum Number Leetcode Solution215
350Find Lucky Integer in an Array Leetcode Solution215
351Maximum Subarray215
352Count subarrays having total distinct elements same as original array215
353Convex Hull Algorithm215
354Minimum operation to make all elements equal in array214
355Top K Frequent Words214
356Sorting array using Stacks214
357Longest Substring Without Repeating Characters LeetCode Solution214
358Permutations Leetcode Solution214
359Find the Town Judge Leetcode Solution213
360Find Numbers with Even Number of Digits Leetcode Solution212
361Evaluate Division211
362Special Number211
363Number of Good Pairs Leetcode Solution210
364Given two unsorted arrays find all pairs whose sum is x210
365Majority Element Leetcode Solution210
366Swap Nodes in Pairs Leetcode Solutions210
367First element occurring k times in an array209
368Minimum Path Sum209
369Spiral Matrix LeetCode Solution209
370Huffman Coding209
371Prefix to Infix Conversion208
372Check if two arrays are equal or not208
373Reversing the First K elements of a Queue207
374Reverse a Number Using Stack207
375Single Number207
376Maximal Square207
377Merge Two Sorted Lists Leetcode Solutions207
378Count Primes Leetcode Solutions207
379Best Time to Buy and Sell Stock  II Leetcode Solution206
380Pascal’s Triangle II Leetcode Solution206
381Group Anagrams206
382Missing Number Leetcode Solution206
383Minimum Absolute Difference Leetcode Solution205
384Find duplicates in a given array when elements are not limited to a range205
385Minimum Steps to reach target by a Knight205
386Search in Rotated Sorted Array Leetcode Solution205
387Running Sum of 1d Array Leetcode Solution205
388Palindrome Substring Queries204
389Maximum Distance Between two Occurrences of Same Element in Array204
390House Robber II Leetcode Solution204
391Sort Array by Increasing Frequency Leetcode Solution204
392Power of Two Leetcode Solution203
393Matrix Diagonal Sum Leetcode Solution203
394Range Sum Query 2D – Immutable Leetcode Solution202
395Find Minimum In Rotated Sorted Array202
396Top K Frequent Elements202
397Convert String To Int202
398Find the first repeating element in an array of integers202
399Unique Paths202
400Find All Numbers Disappeared in an Array Leetcode Solution202
401How to Implement Stack Using Priority Queue or Heap?202
402Maximum possible difference of two subsets of an array202
403Zigzag Conversion202
404Subarray Sum Equals k201
405Find the Closest Palindrome number201
406Fizz Buzz Leetcode201
407Check if Array Contains Contiguous Integers With Duplicates Allowed201
408Sorting using trivial hash function201
409Unique Paths Leetcode Solution201
410Expression Contains Redundant Bracket or Not201
411Smallest Element Repeated Exactly K Times201
412Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution200
413Sort Integers by The Number of 1 Bit Leetcode Solution200
414How Many Numbers Are Smaller Than the Current Number Leetcode Solution200
415Leetcode Permutations200
416Subset sum problem199
417Max Consecutive Ones Leetcode Solution199
418Cumulative Frequency of Count of Each Element in an Unsorted Array199
419Decode String199
420Find Number of Employees Under every Employee199
421Letter Case Permutation199
422Find Winner on a Tic Tac Toe Game Leetcode Solution199
423Monotonic Array LeetCode Solution198
424Difference between highest and least frequencies in an array198
425Happy Number Leetcode Solution198
426Length of the largest subarray with contiguous elements198
427Coin Change 2 Leetcode Solution198
428Reverse Integer197
429Print All Distinct Elements of a Given Integer Array197
430Find top three repeated in array197
431Best Time to Buy and Sell Stock III Leetcode Solution197
432Nth Catalan Number197
433Sort a stack using recursion197
434Subarray Sum Equals K LeetCode Solution197
435Implement Stack and Queue using Deque197
436Print all subarrays with 0 sum196
437Check If N and Its Double Exist Leetcode Solution196
438LRU Cache Implementation196
439Fibonacci Number LeetCode Solution196
440Maximum Depth of Binary Tree Leetcode Solution196
441Count Substrings with equal number of 0s, 1s and 2s196
442Remove Duplicates from Sorted Array Leetcode Solution196
443Subarrays with distinct elements195
444Reverse Vowels of a String Leetcode Solution195
445Sum of Subarray Ranges Leetcode Solution195
446Capacity To Ship Packages Within D Days Leetcode Solution195
447Reverse a Stack Using Recursion194
448Prim’s Algorithm194
449Generate a String With Characters That Have Odd Counts Leetcode Solution194
450Find The Duplicate Number194
451Subtract the Product and Sum of Digits of an Integer Leetcode Solution194
452Find Median from data Stream194
453Integer to English words193
454Merge Two Sorted Linked Lists193
455Reverse Words in a String III LeetCode Solution193
456Delete a Node from linked list without head pointer193
457Kth largest element in an Array Leetcode Solutions193
458Shuffle the Array Leetcode Solution193
459Bipartite Graph193
460Trapping Rain Water Leetcode Solution192
461Find elements which are present in first array and not in second192
462Edit Distance192
463Count and Say192
464Find all pairs (a, b) in an array such that a % b = k192
465Target Sum192
466Find Common Characters Leetcode Solution192
467Count pairs from two linked lists whose sum is equal to a given value192
468Find the Duplicate Element192
469Find the Difference Leetcode Solution192
470Sorting a Queue without Extra Space191
471Reverse a String191
472Remove Minimum Number of Elements Such That no Common Element Exist in both Array191
473Longest Common Subsequence191
474Priority Queue Using Singly Linked List190
475Iterative Tower of Hanoi190
476Fizz Buzz190
477Excel Sheet Column Number Leetcode Solution190
478The K Weakest Rows in a Matrix Leetcode Solution190
479Floyd Warshall Algorithm190
480Balanced Binary Tree Leetcode Solution190
481Text Justification LeetCode Solution189
482Reverse a linked list189
483Concatenation of Array LeetCode Solution189
484Longest Common Prefix using Trie189
485Longest subarray not having more than K distinct elements188
486Degree of an array188
487Prefix to Postfix Conversion188
488Kids With the Greatest Number of Candies Leetcode Solution188
489Kth Largest Element in a Stream Leetcode Solution188
490Merge Overlapping Intervals188
491Design Parking System Leetcode Solution188
492Minimum Moves to Equal Array Elements Leetcode Solution188
493Flood Fill LeetCode188
494Next Greater Element I Leetcode Solution188
495Find First and Last Position of Element in Sorted Array Leetcode Solution188
496Slowest Key Leetcode Solution187
497Top View of Binary Tree187
498Number of Steps to Reduce a Number to Zero Leetcode Solution187
499Find subarray with given sum (Handles Negative Numbers)187
500Valid Parenthesis String187
501MiniMax Algorithm187
502Word Ladder LeetCode Solution187
503Find missing elements of a range186
504Zigzag Conversion LeetCode Solution186
505Multiply Strings Leetcode Solution186
506Find four elements that sum to a given value (Hashmap)186
507Shortest Palindrome186
508Priority Queue in C++186
509Pair with given product186
510Find N Unique Integers Sum up to Zero Leetcode Solution186
511The Stock Span Problem186
512Jump Game Leetcode Solution185
513Convert array into Zig-Zag fashion185
514Postfix to Prefix Conversion185
515Max Area of Island185
516Count and Say Leetcode Solution185
517Mobile Numeric Keypad Problem184
518Length of Last Word Leetcode Solution184
519Find Index of Closing Bracket for a Given Opening Bracket in an Expression184
520Count number of triplets with product equal to given number184
521Move Zeroes LeetCode Solution184
522Check if a given array contains duplicate elements within k distance from each other184
523Substring With Concatenation Of All Words184
524Rearrange a binary string as alternate x and y occurrences184
525Recursion184
526Implement a stack using single queue184
527Find distinct elements common to all rows of a matrix184
528Find any one of the multiple repeating elements in read only array184
529Shuffle String Leetcode Solution183
530Implement Stack using Queues183
531Longest Common Prefix using Sorting183
532Next Greater Frequency Element183
533Intersection of Two Arrays183
534Largest Sum Contiguous Subarray183
535Peak Index in a Mountain Array183
536Smallest Subarray With all Occurrences of a Most Frequent Element182
537Last Stone Weight182
538Contiguous Array Leetcode182
539Iterative Inorder Traversal of a Binary Tree182
540Change the Array into Permutation of Numbers From 1 to N181
541Convert a normal BST to Balanced BST181
542Relative Sort Array Leetcode Solution181
543Sum of Left Leaves Leetcode Solutions181
544Koko Eating Bananas Leetcode Solution181
545Excel Sheet Column Title Leetcode Solution181
546Delete Node in a Linked List Leetcode Solution181
547Group Multiple Occurrence of Array Elements Ordered by first Occurrence181
548Linked List Cycle II LeetCode Solution180
549Minimum Bracket Reversals180
550Valid Sudoku180
551Best Time to Buy and Sell Stock180
552K-th Distinct Element in an Array180
553Assign Cookies Leetcode Solution180
554Number of Provinces Leetcode Solution179
555Shuffle an Array179
556First negative integer in every window of size k179
557Container with Most Water179
558Distribute Candies to People Leetcode Solution179
559Find Words That Can Be Formed by Characters Leetcode Solution179
560Integer to Roman179
561Minimum Operations to convert X to Y179
562Is Subsequence Leetcode Solution179
563Implementation of Deque using circular array179
564Island Perimeter Leetcode Solution179
565Minimum Delete Operations to make all Elements of Array Same179
566Isomorphic Strings Leetcode Solution179
567N-th Tribonacci Number Leetcode Solution179
568Build Array From Permutation Leetcode Solution178
569Hamming Distance178
570Largest Perimeter Triangle Leetcode Solution178
571Minimum Knight Moves LeetCode Solution178
572Jewels and Stones Leetcode Solution178
573Check for Balanced Parentheses in an Expression178
574Arrange given numbers to form the biggest number178
575Convert Sorted Array to Binary Search Tree Leetcode Solution177
576Valid Anagrams177
577Unique Binary Search Trees177
578Rotate List Leetcode Solution177
57901 Matrix LeetCode Solution177
580Gold Mine Problem177
581The Knapsack Problem177
582Combinations Leetcode Solution177
583Maximum path sum in a triangle177
584Summary Ranges Leetcode Solution177
585Count all subsequences having product less than K177
586Count the number of nodes at given level in a tree using BFS177
587LRU Cache LeetCode Solution176
588Maximum sum rectangle in a 2D matrix176
589Remove Linked List Elements Leetcode Solution176
590Trapping Rain Water LeetCode Solution176
591Decode Ways175
592Find the smallest positive integer value that cannot be represented as sum of any subset of a given array175
593Minimum number of subsets with distinct elements175
594Shortest Path in a Grid with Obstacles Elimination LeetCode Solution175
5953Sum Closest LeetCode Solution175
596Rotate Image LeetCode Solution174
597Maximum Distance in Array174
598Minimum insertions to form a palindrome with permutations allowed174
599Find minimum difference between any two elements174
600Find Sum of all unique sub-array sum for a given array174
601Minimum number of distinct elements after removing m items174
602Bubble sort using two Stacks173
603How to check if two given sets are disjoint?173
604Insert Interval Leetcode Solution173
605Distance Between Bus Stops Leetcode Solution173
606Same Tree LeetCode Solution173
607Sort Characters By Frequency LeetCode Solution173
608Maximum Number of Chocolates to be Distributed Equally Among k Students173
609Minimum Cost to Hire K Workers172
610Longest Increasing Subsequence172
611Defanging an IP Address Leetcode Solution172
612Stone Game LeetCode172
613Find if an Expression has Duplicate Parenthesis or Not172
614Painting Fence Algorithm172
615Sieve of Eratosthenes172
616Frog Jump Leetcode Solution172
617XOR Operation in an Array Leetcode Solution172
618Reverse a stack without using extra space in O(n)172
619Replace Elements with Greatest Element on Right Side Leetcode Solution171
620Applications of Breadth First Search and Depth First Search171
621Permutation in String Leetcode Solution171
622Word Wrap Problem171
623Find the Duplicate Number LeetCode Solution171
624Word Pattern171
625Remove All Occurrences of a Substring LeetCode Solution171
626License Key Formatting Leetcode Solution171
627Non-overlapping sum of two sets170
628Printing brackets in Matrix Chain Multiplication Problem170
629Distance of nearest cell having 1 in a binary matrix170
630Iterative Method to find Height of Binary Tree170
631House Robber170
632Maximum Consecutive Numbers Present in an Array170
633Isomorphic Strings170
634K Empty Slots LeetCode170
635Smallest Good Base170
636Sort Array By Parity LeetCode Solution170
637Best Time to Buy and Sell Stock LeetCode Solution170
638Segregate 0s and 1s in an Array169
639Tracking current Maximum Element in a Stack169
640Moving Average from Data Stream Leetcode Solution169
641Optimal Account Balancing LeetCode Solution169
642Minimum Depth of Binary Tree Leetcode Solution169
643Longest Substring with At Least K Repeating Characters LeetCode Solution169
644GCD Of Two Numbers168
645Wiggle Sort168
646Longest Substring with At Most K Distinct Characters LeetCode Solution168
647Binary Tree Zigzag Level Order Traversal LeetCode Solution168
648Valid Palindrome II Leetcode Solution168
649Queries for counts of array elements with values in given range168
650Kth Missing Positive Number Leetcode Solution168
651Best Time to Buy and Sell Stock with Cooldown Leetcode Solution168
652Merge Two Balanced Binary Search Trees168
653Employee Free Time LeetCode Solution168
654Coin Change Problem168
655Sum of All Odd Length Subarrays Leetcode Solution167
656Path With Maximum Minimum Value LeetCode Solution167
657Maximum difference between first and last indexes of an element in array167
658Find Maximum Level sum in Binary Tree167
659Check If It Is a Straight Line Leetcode Solution167
660Count Good Nodes in Binary Tree Leetcode Solution167
661Valid Palindrome167
662How to Create Mergable Stack?167
663Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions167
664Reorganize String167
665Strobogrammatic Number LeetCode Solution167
666Flipping an Image LeetCode Solution166
667Find Largest d in Array such that a + b + c = d166
668Delete consecutive same words in a sequence166
669Remove Invalid Parentheses Leetcode Solution166
670To Lower Case Leetcode Solution166
671Maximum Number of Occurrences of a Substring Leetcode Solution166
672Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest166
673Check if a queue can be sorted into another queue using a stack166
674Find the Distance Value Between Two Arrays Leetcode Solution166
675Reducing Dishes LeetCode Solution165
676K Empty Slots165
677Check If Two String Arrays are Equivalent Leetcode Solution165
678Increasing Decreasing String Leetcode Solution165
679Letter Combinations of a Phone Number165
680Partition Labels LeetCode Solution165
681Convert an array to reduced form165
682Sum of f(a[i], a[j]) over all pairs in an array of n integers165
683Partition Array Into Three Parts With Equal Sum Leetcode Solution165
684Print the Fibonacci numbers in reverse order165
685Lucky Numbers in a Matrix Leetcode Solution165
686Inorder Successor of a node in Binary Tree165
687Find pairs with given sum such that elements of pair are in different rows165
688Maximum Number of Coins You Can Get Leetcode Solution165
689Valid Perfect Square Leetcode Solution164
690Find the Smallest Divisor given a Threshold Leetcode Solution164
691Permutation Sequence LeetCode Solution164
692BFS vs DFS for Binary Tree164
693Factorial Trailing Zeroes Leetcode Solution164
694Reverse Only Letters LeetCode Solution164
695Delete Nth node from the end of the given linked list164
696Number of Dice Rolls With Target Sum LeetCode Solution164
697Convert a Number to Hexadecimal Leetcode Solution163
698Power of Four Leetcode Solution163
699Maximum Product of Two Elements in an Array Leetcode Solution163
700Unique Paths II Leetcode Solution163
701Ugly Number Leetcode Solution163
702Reversing a Queue using Recursion163
703String to Integer (atoi) LeetCode Solution163
704Form minimum number from given sequence163
705Edit Distance LeetCode Solution163
706Find Leaves of Binary Tree LeetCode Solution163
707Binary Tree zigzag level order Traversal163
708Subset Sum Leetcode163
709Find whether an array is subset of another array163
710Populating Next Right Pointers in Each Node163
711Recover Binary Search Tree163
712Longest Increasing Path in a Matrix LeetCode Solution163
713Dynamic Programming Basics163
714Sort Array by Increasing Frequency Leetcode Solution162
715Perform String Shifts Leetcode162
716Construct BST from given Preorder Traversal162
717Reservoir Sampling162
718Merge Two Binary Trees LeetCode Solution162
719Robot Room Cleaner Leetcode Solution162
720Decompress Run-Length Encoded List Leetcode Solution161
721Add and Search Word – Data structure design LeetCode161
722Keyboard Row Leetcode Solution161
723Find the node with minimum value in a Binary Search Tree161
724Find the largest multiple of 3161
725Binomial Coefficient161
726Find Pair with Greatest Product in Array160
727Finding K closest element160
728Tiling Problem160
729Minimum Cost For Tickets Leetcode Solution160
730Bulb Switcher LeetCode Solution160
731Majority Element II Leetcode Solution160
732Hamming Distance Leetcode Solution160
733Restore IP Addresses Leetcode Solution160
734Student Attendance Record I Leetcode Solution160
735Longest Span with same Sum in two Binary arrays159
736Remove brackets from an algebraic string containing + and – operators159
737Generate all possible sorted arrays from alternate elements of two given sorted arrays159
738Find Maximum Depth of Nested Parenthesis in a String159
739Non-decreasing Array LeetCode Solution159
740Minimum Distance Between BST Nodes Leetcode Solution159
741Rank Transform of an Array Leetcode Solution159
742Binary Tree Maximum Path Sum LeetCode Solution159
743Word Pattern LeetCode Solution159
744Snakes and Ladders LeetCode Solution159
745Numbers with prime frequencies greater than or equal to k159
746Kth ancestor of a node in binary tree159
747Find unique character in a string159
748Check if Two Expressions With Brackets are Same159
749Race Car LeetCode Solution159
750Maximum 69 Number Leetcode Solution158
751Minimum Height Trees158
752Maximum Depth of N-ary Tree Leetcode Solution158
753Number of Islands II LeetCode Solution158
754Sorted Linked List to Balanced BST158
755Stack Permutations (Check if an array is stack permutation of other)158
756Linked List Cycle158
757Diagonal Traversal of Binary Tree158
758Morris Traversal158
759First Unique Character in a String LeetCode Solution158
760Invert Binary Tree LeetCode Solution158
761Queue based approach for first non-repeating character in a stream158
762String Compression LeetCode Solution158
763Maximum Product of Three Numbers LeetCode Solution158
764Largest Rectangle in Histogram LeetCode Solution158
765Minimum time required to rot all oranges158
766Merge K Sorted Linked Lists158
767Remove Nth Node From End of List Leetcode Solution157
768Best Meeting Point LeetCode Solution157
769Transpose Graph157
770Final Prices With a Special Discount in a Shop Leetcode Solution157
771Minimize Maximum Pair Sum in Array LeetCode Solution157
772Find if Path Exists in Graph Leetcode Solution157
773Largest subarray with equal number of 0s and 1s157
774Largest rectangular sub-matrix whose sum is 0157
775Jump Game157
776Total Numbers With no Repeated Digits in a Range156
777k-th missing element in increasing sequence which is not present in a given sequence156
778Evaluate Reverse Polish Notation LeetCode Solution156
779Maximum Difference Between Increasing Elements LeetCode Solution156
780Program for Bridge and Torch problem156
781Special Array With X Elements Greater Than or Equal X Leetcode Solution156
782Partition to K Equal Sum Subsets Leetcode Solution156
783One Edit Distance LeetCode Solution156
784Check If Array Pairs Are Divisible by k LeetCode Solution156
785Find All Duplicates in an Array LeetCode Solution156
786Elements to be added so that all elements of a range are present in array156
787Growable array based stack156
788Symmetric Tree Leetcode Solution156
789Maximum Length of a Concatenated String with Unique Characters Leetcode Solution156
790Count items common to both the lists but with different prices155
791Crawler Log Folder Leetcode Solution155
792Sort an array according to the order defined by another array155
793Search in a Binary Search Tree Leetcode Solution155
794Print a Binary Tree in Vertical Order155
795Number of NGEs to the Right155
796Search a 2D Matrix II Leetcode Solution155
797Longest Subarray Having Count of 1s One More than Count of 0s155
798Split a String in Balanced Strings Leetcode Solution155
799Check for Palindrome after every character replacement Query155
800Find Median from Data Stream LeetCode Solution155
801Interval Tree155
802Nested List Weight Sum II LeetCode Solution154
803Base 7 Leetcode Solution154
804Course Schedule II – LeetCode154
805N-Queens LeetCode Solution154
806Minimum Time Visiting All Points Leetcode Solution154
807Circular Queue154
808Minimum swaps to make sequences increasing154
809Merge Sorted Array LeetCode Solution154
810Number Complement Leetcode Solution154
811Count quadruples from four sorted arrays whose sum is equal to a given value x154
812Minimum Jumps to Reach Home LeetCode Solution154
813String comparison containing wildcards154
814Nearest Exit from Entrance in Maze LeetCode Solution154
815Deletion in a Binary Tree154
816Valid Number154
817Reorder Data in Log Files LeetCode Solution153
818Maximum Profit in Job Scheduling Leetcode Solution153
819Sort Array By Parity II Leetcode Solution153
820Minimum number of jumps to reach end153
821Remove Duplicates from Sorted List II153
822A Space Optimized DP solution for 0-1 Knapsack Problem153
823Last Stone Weight II LeetCode Solution153
824Get Maximum in Generated Array Leetcode Solution153
825Convert BST to Min Heap153
826Spiral Matrix II Leetcode Solution153
827Find the subarray with least average152
828Regular Expression Matching152
829Maximum size subarray sum equals k152
830Subarray Product Less Than K LeetCode Solution152
831Minimum Swaps to Make Strings Equal Leetcode Solution152
832Relative Ranks Leetcode Solution152
833Find Maximum Sum Possible Equal Sum of Three Stacks152
834Form Minimum Number From Given Sequence152
835Find all triplets with zero sum152
836Priority Queue using doubly linked list152
837Remove Duplicates from Sorted List LeetCode Solution152
838Iterative Preorder Traversal152
839Identify and Mark Unmatched Parenthesis in an Expression151
840Partition List Leetcode Solution151
841Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution151
842Sort Colors151
843Sequences of given length where every element is more than or equal to twice of previous151
844LCS (Longest Common Subsequence) of three strings151
845Insert into a Binary Search Tree Leetcode Solution151
846Permutation Coefficient151
847Can Place Flowers LeetCode Solution151
848Tree Traversal (Preorder, Inorder & Postorder)151
849Path with maximum average value151
850Alien Dictionary LeetCode Solution151
851Maximum Nesting Depth of the Parentheses Leetcode Solution151
852Number of Days Between Two Dates LeetCode Solution151
853Subset with sum divisible by m151
854Binary Search Tree Search and Insertion150
855Find All Possible Recipes from Given Supplies LeetCode Solution150
856Minimum Number of Taps to Open to Water a Garden LeetCode Solution150
857Check if a given array can represent Preorder Traversal of Binary Search Tree150
858Check whether a given Binary Tree is Complete or not150
859Design a Stack With Increment Operation Leetcode Solution150
860Sum of nearest smaller and greater number150
861Count Negative Numbers in a Sorted Matrix LeetCode Solution150
862Guess Number Higher or Lower LeetCode Solution150
863Top K Frequent Words LeetCode Solution150
864Valid Parentheses Leetcode Solution150
865Given an Array of Pairs Find all Symmetric Pairs in it150
866Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution150
867Minimum Sum Path in a Triangle150
868Count Distinct Elements in Every Window of Size K150
869Brick Wall LeetCode Solution150
870Find the Only Repetitive Element Between 1 to N-1150
871Level order Traversal in Spiral Form150
872Friends Pairing Problem150
873Subsequence of Size K With the Largest Even Sum LeetCode Solution150
874Missing Element in Sorted Array LeetCode Solution149
875Find distance between two nodes of a Binary Tree149
876Brightest Position on Street LeetCode Solution149
877Range LCM Queries149
878Repeated Substring Pattern LeetCode Solution149
879Matrix Chain Multiplication149
880Clone Graph LeetCode Solution149
881Balanced Expression with Replacement149
882Sorted Array to Balanced BST149
883GCDs of given index ranges in an array149
884Destination City Leetcode Solution149
885Check if stack elements are pairwise consecutive149
886Find Common Characters Leetcode Solution149
887Range sum queries without updates149
888Union and Intersection of two Linked Lists149
889Distinct adjacent elements in an array149
890An Interesting Method to generate Binary Numbers from 1 to n148
891Minimum sum of multiplications of n numbers148
892Construct Complete Binary Tree from its Linked List Representation148
893K’th Largest Element in BST when modification to BST is not allowed148
894Count ways to reach the nth stair using step 1, 2 or 3148
895Check if an Array is Stack Sortable148
896Shortest Word Distance Leetcode Solution148
897Diagonal Traverse LeetCode Solution148
898Water Bottles Leetcode Solution148
899BFS for Disconnected Graph148
900Rearrange an Array Such that arr[i] is equal to i148
901Design Browser History LeetCode Solution148
902Time Based Key-Value Store LeetCode Solution148
903Three way partitioning of an array around a given range148
904Least Number of Unique Integers after K Removals Leetcode Solution147
905Averages of Levels in Binary Tree147
906Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i147
907Rearrange Spaces Between Words Leetcode Solution147
908Delete And Earn147
909Spiral Matrix III LeetCode Solution147
910Lemonade Change Leetcode Solution147
911Convert Sorted List to Binary Search Tree147
912Guess Number Higher or Lower II147
913Diagonal Traversal LeetCode Solution147
914Daily Temperatures Leetcode Solution147
915Queries for GCD of all numbers of an array except elements in a given range147
916Insert Delete GetRandom147
917Queue using Stacks146
918Maximum Score After Splitting a String Leetcode Solution146
919Robot Bounded In Circle LeetCode Solution146
920Find all permuted rows of a given row in a matrix146
921Set Matrix Zeroes Leetcode Solution146
922Count Subarrays with Same Even and Odd Elements146
923Special Positions in a Binary Matrix Leetcode Solution146
924Vertical sum in a given binary tree146
925Binary Tree Longest Consecutive Sequence LeetCode Solution145
926Merge Two Sorted Lists Leetcode145
927Alien Dictionary145
928Dividing Array into Pairs With Sum Divisible by K145
929Iterative Postorder Traversal Using Two Stacks145
930Check if any two intervals overlap among a given set of intervals145
931Construct the Rectangle Leetcode Solution145
932Largest area rectangular sub-matrix with equal number of 1’s and 0’s145
933Maximum Subarray Sum Excluding Certain Elements145
934Split Array Into Consecutive Subsequences145
935A program to check if a binary tree is BST or not145
936Number of Distinct Islands Leetcode Solution145
937Check if the given array can represent Level Order Traversal of Binary Search Tree145
938Palindrome Partitioning Leetcode Solution145
939Median of Two Sorted Arrays145
9403 Sum144
9414Sum144
942Print Fibonacci sequence using 2 variables144
943Lexicographical Numbers Leetcode Solution144
944Construct BST from its given Level Order Traversal144
945Longest Palindromic Subsequence144
946Three Consecutive Odds Leetcode Solution144
947All Unique Triplets that Sum up to a Given Value144
948Number of Equivalent Domino Pairs Leetcode Solution143
949Remove Duplicates from Sorted List II LeetCode Solution143
950Stone Game II Leetcode143
951Maximum Product Subarray143
952Difference Array | Range update query in O(1)143
953Strongly Connected Component143
954Maximize Sum of Array after K Negations Leetcode Solution143
955Analyze User Website Visit Pattern LeetCode Solution143
956Maximum Frequency Stack Leetcode Solution143
957Create Maximum Number143
958Sliding Window Maximum143
959Count Submatrices With All Ones LeetCode Solution143
960Minimum Height Trees LeetCode Solution143
961Binary array after M range toggle operations142
962Unique Paths II142
963Length of Longest Fibonacci Subsequence142
964Can Make Arithmetic Progression From Sequence Leetcode Solution142
965Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space142
966Trim a Binary Search Tree142
967My Calendar I LeetCode Solution142
968Infix to Postfix142
969Count subarrays where second highest lie before highest142
970Collect maximum points in a grid using two traversals142
971Symmetric Tree141
972Find the Difference Leetcode Solution141
973Count Primes in Ranges141
974Find postorder traversal of BST from preorder traversal141
975The Painter’s Partition Problem141
976Intersection of Two Linked Lists LeetCode Solution141
977Merging Intervals141
978Find Maximum of Minimum for Every Window Size in a Given Array141
979Minesweeper LeetCode Solution141
980Kth Smallest Element in a BST Leetcode Solution141
981Palindrome Partitioning140
982Boundary Traversal of binary tree140
983Product of Array Except Self LeetCode Solution140
984Climbing stairs140
985Valid Boomerang Leetcode Solution140
986Height of a generic tree from parent array140
987Count pair with Given Sum140
988Word Break140
989Longest Nice Substring LeetCode Solution140
990Pattern Occurrences using Stack140
991K Closest Points to Origin Leetcode Solution140
992Reverse Nodes in K-Group140
993Sign of the Product of an Array LeetCode Solution140
994Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution140
995Minimum Index Sum of Two Lists140
996Segment Tree139
997Find the First Circular Tour that visits all the Petrol Pumps139
998Largest divisible pairs subset139
999Asteroid Collision LeetCode Solution139
1000Maximum length subsequence with difference between adjacent elements as either 0 or 1139
1001Graph Valid Tree LeetCode Solution139
1002Breadth First Search (BFS) for a Graph139
1003Maximum Sum of 3 Non-Overlapping Subarrays139
1004Number Of Longest Increasing Subsequence139
1005Newman-Conway Sequence139
1006Largest Number Leetcode Solution139
1007Level Order Traversal of Binary Tree139
1008Largest Substring Between Two Equal Characters Leetcode Solution139
1009Friends Of Appropriate Ages LeetCode Solution139
1010Binary Search Tree Delete Operation139
1011Find Duplicate Subtrees138
1012Scramble String LeetCode Solution138
1013Construction of Longest Increasing Subsequence (N log N)138
1014Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’138
1015Maximum Number of Ways to Partition an Array LeetCode Solution138
1016K maximum sums of overlapping contiguous sub-arrays138
1017Rearrange array such that even positioned are greater than odd138
1018Double the first element and move zero to end138
1019Boolean Parenthesization Problem138
1020The Maze III LeetCode Solution138
1021Merge Sort138
1022Next Greater Element III LeetCode Solution138
1023Insertion in a Binary Tree138
1024Find number of pairs in an array such that their XOR is 0138
1025Maximum subsequence sum such that no three are consecutive138
1026Construct Binary Tree from given Parent Array representation138
1027Compute nCr % p138
1028Maximum Length of Repeated Subarray138
1029Shortest Completing Word Leetcode Solution138
1030Longest subsequence such that difference between adjacents is one138
1031Decrypt String from Alphabet to Integer Mapping Leetcode Solution137
1032Kill Process LeetCode Solution137
1033Ugly Numbers137
1034Make The String Great Leetcode Solution137
1035Binary Search Tree137
1036Depth First Search (DFS) for a Graph137
1037Maximum Product of Indexes of Next Greater on Left and Right137
1038Design Hit Counter LeetCode Solution137
1039Number of palindromic paths in a matrix137
1040Iterative Depth First Traversal of Graph137
1041Build an Array With Stack Operations Leetcode Solution137
1042Maximum weight transformation of a given string137
1043String Matching in an Array Leetcode Solution137
1044Partition Equal Subset Sum137
1045Available Captures for Rook Leetcode Solution136
1046First missing positive136
1047Advantages of BST over Hash Table136
1048Level order traversal using two Queues136
1049Count minimum steps to get the given desired array136
1050Serialize and Deserialize Binary Tree136
1051Morris Inorder Traversal136
1052Lowest Common Ancestor135
1053Invalid Transactions LeetCode Solution135
1054Find a Peak Element II LeetCode Solution135
1055Add two numbers135
1056Maximum difference between frequency of two elements such that element having greater frequency is also greater135
1057Custom Sort String Leetcode Solution135
1058Bitwise AND of Numbers Range LeetCode Solution135
1059Balanced Binary Tree135
1060Kth Smallest Element in a Sorted Matrix LeetCode Solution135
1061Regular Expression Matching Regular Expression Matching LeetCode Solution134
1062Path Sum II LeetCode Solution134
1063Remove Duplicates from Sorted Array II Leetcode Solution134
1064Ugly Number II LeetCode Solution134
1065Minimum Size Subarray Sum134
1066Super Ugly Number134
1067Combination Sum IV LeetCode Solution134
1068Find Peak Element134
1069Employee Importance LeetCode Solution134
1070Validate Binary Search Tree134
1071Count pairs from two sorted arrays whose sum is equal to a given value x134
1072Generate Parentheses Leetcode Solution134
1073Root to Leaf path with target sum Leetcode Solutions133
1074Recover Binary Search Tree Leetcode Solution133
1075Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution133
1076Implement Trie (Prefix Tree) Leetcode Solution133
1077Defanging an IP Address LeetCode Solution133
1078Find whether a subarray is in form of a mountain or not133
1079Binary Tree Right Side View LeetCode Solution133
1080Rearrange array such that even index elements are smaller and odd index elements are greater133
1081Increasing Triplet Subsequence LeetCode Solution133
1082Move all negative elements to end in order with extra space allowed133
1083Number of Closed Islands Leetcode Solution132
1084Subarrays with K Different Integers Leetcode Solution132
1085Search in Sorted Rotated Array132
1086Populating Next Right Pointers in Each Node Leetcode Solution132
1087Largest BST Subtree LeetCode Solution132
1088Consecutive Characters LeetCode Solution132
1089Day of the Year Leetcode Solution132
1090Find Smallest Range Containing Elements from k Lists131
1091Smallest Common Region Leetcode Solution131
1092Types of Binary Tree131
1093Remove Palindromic Subsequences Leetcode Solution131
1094Serialize and Deserialize Binary Tree LeetCode Solution131
1095Count Largest Group Leetcode Solution131
1096Number of Students Doing Homework at a Given Time Leetcode Solution131
1097Longest Bitonic Subsequence131
1098Distinct Subsequences130
1099Find maximum difference between nearest left and right smaller elements130
1100Clone a Binary Tree with Random Pointers130
1101Remove duplicates from sorted array130
1102Find the minimum distance between two numbers130
1103Maximize Distance to Closest Person LeetCode Solution130
1104Number of siblings of a given Node in n-ary Tree130
1105Kth Smallest Product of Two Sorted Arrays LeetCode Solution130
1106Minimum Absolute Difference in BST Leetcode Solution130
1107Level of Each node in a Tree from source node130
1108Find Three Element From Different Three Arrays Such That a + b + c = sum130
1109Binary Tree Data Structure130
1110Next Permutation Leetcode Solution130
1111Convert BST into a Min-Heap without using array130
1112Print all triplets in sorted array that form AP130
1113Construct K Palindrome Strings LeetCode Solution129
1114Write Code to Determine if Two Trees are Identical129
1115Thousand Separator Leetcode Solution129
1116Bottom View of a Binary Tree129
1117Third Maximum Number Leetcode Solution129
1118Palindrome Permutation LeetCode Solution129
1119Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution129
1120Path Sum129
1121Sum of Even Numbers After Queries129
1122Print Next Greater Number of Q queries129
1123Cutting a Rod129
1124Divisible Pairs Counting129
1125Maximum Product Subarray128
1126Diameter of N-Ary Tree LeetCode Solution128
1127Minimum sum of squares of character counts in a given string after removing k characters128
1128Valid Tic-Tac-Toe State LeetCode Solution128
1129Products of ranges in an array128
1130Reformat The String Leetcode Solution128
1131Minimum Score Triangulation of Polygon Leetcode Solution128
1132Iterative method to find ancestors of a given binary tree128
1133Mean of Array After Removing Some Elements Leetcode Solution128
1134Longest Increasing Consecutive Subsequence128
1135Print Right View of a Binary Tree128
1136Queries for Number of Distinct Elements in a Subarray128
1137Constant time range add operation on an array128
1138Delete Nodes and Return Forest Leetcode Solution128
1139Prime Palindrome LeetCode Solution127
1140Maximum Product of Splitted Binary Tree LeetCode Solution127
1141Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution127
1142Longest Subarray of 1’s After Deleting One Element LeetCode Solution127
1143Swap Nodes In Pairs126
1144Subset Sum Problem in O(sum) space126
1145Palindromic Substrings Leetcode Solution126
1146Moser-de Bruijn Sequence126
1147Find maximum length Snake sequence126
1148Search an Element in Sorted Rotated Array126
1149Search Insert Position126
1150Cells with Odd Values in a Matrix LeetCode Solution126
1151Red-Black Tree Introduction125
1152Topological Sorting125
1153Print modified array after executing the commands of addition and subtraction125
1154Priority Queue125
1155Transform a BST to Greater sum Tree125
1156Kth Smallest Number in Multiplication Table Leetcode Solution125
1157Merge two BSTs with limited extra space125
1158Maximum Binary Tree125
1159Bus Routes Leetcode Solution125
1160Check Array Formation Through Concatenation Leetcode Solution124
1161Closest Binary Search Tree Value Leetcode Solution124
1162Maximize sum of consecutive differences in a circular array124
1163Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution124
1164Golomb sequence123
1165Minimum Cost to Move Chips to The Same Position LeetCode Solution123
1166Find Largest Value in Each Tree Row LeetCode Solution123
1167Decision Tree123
1168Search Suggestions System LeetCode Solution123
1169Rotate Array123
1170Minimum Sideway Jumps LeetCode Solution123
1171Given a binary tree, how do you remove all the half nodes?123
1172Web Crawler LeetCode Solution123
1173Possible Bipartition LeetCode Solution123
1174K’th Largest element in BST using constant extra space123
1175Count even length binary sequences with same sum of first and second half bits123
1176Contiguous Array LeetCode Solution122
1177Find a sorted subsequence of size 3 in linear time122
1178Maximum number of segments of lengths a, b and c122
1179Longest Repeated Subsequence122
1180Compare Strings by Frequency of the Smallest Character Leetcode Solution122
1181Minimum Moves to Equal Array Elements LeetCode Solution122
1182Binary Tree to Binary Search Tree Conversion122
1183Factorial Trailing Zeroes LeetCode Solution122
1184Find the smallest binary digit multiple of given number122
1185Graph and its representation121
1186Swapping Nodes in a Linked List Leetcode Solution121
1187Decrease Elements To Make Array Zigzag LeetCode Solution121
1188Reverse a Path in BST using Queue121
1189Maximum Depth Of Binary Tree121
1190Matchsticks to Square Leetcode Solution121
1191First Bad Version121
1192Closest Leaf in a Binary Tree LeetCode Solution121
1193Lowest Common Ancestor in Binary Search Tree121
1194Sum of Left Leaves LeetCode Solution121
1195Valid Triangle Number121
1196Maximum sum of pairs with specific difference120
1197Reformat Date LeetCode Solution120
1198Count Pairs Whose Products Exist in Array120
1199Queue Reconstruction by Height120
1200Convert Sorted Array to Binary Search Tree LeetCode Solutions120
1201Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution120
1202Range Queries for Longest Correct Bracket Subsequence120
1203Maximum sum bitonic subarray120
1204Number of Orders in the Backlog Leetcode Solution120
1205Lowest Common Ancestor of a Binary Tree Leetcode Solution119
1206How to print maximum number of A’s using given four keys119
1207Concatenation of Array LeetCode Solution119
1208Moving Stones Until Consecutive Leetcode Solution119
1209Champagne Tower LeetCode Solution119
1210Path Crossing Leetcode Solution119
1211Perfect Squares LeetCode Solution118
1212Write a function to get the intersection point of two Linked Lists118
1213BST to a Tree with Sum of all Smaller Keys118
1214Kth Smallest Element in a BST118
1215Divide Two Integers Leetcode Solution118
1216Minimum Swaps To Make Sequences Increasing LeetCode Solution118
1217Queries on Probability of Even or Odd Number in given Ranges118
1218Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution117
1219LRU Cache Leetcode Solution117
1220Replace two consecutive equal values with one greater117
1221Maximize Elements Using Another Array117
1222Check if all levels of two Binary Tree are anagrams or not117
1223Array Queries for multiply replacements and product117
1224Integer Break LeetCode Solution117
1225Guess The Word117
1226Valid Perfect Square LeetCode Solution117
1227Maximum Value at a Given Index in a Bounded Array LeetCode Solution117
1228Flatten 2D Vector LeetCode Solution116
1229Sliding Window Median Leetcode Solution116
1230Mean of range in array116
1231Power of Two116
1232Count Subsets Having Distinct Even Numbers116
1233Maximum sum of a path in a Right Number Triangle116
1234New 21 Game116
1235The kth Factor of n Leetcode Solution115
1236Arithmetic Slices II – Subsequence LeetCode Solution115
1237Check Completeness of a Binary Tree LeetCode Solution115
1238Parallel Courses II LeetCode Solution115
1239Missing Number115
1240Print modified array after multiple array range increment operations115
1241Maximum Array from Two given Arrays Keeping Order Same115
1242Range Sum Query using Sparse Table115
1243Design Skiplist LeetCode Solution115
1244Bold Words in String LeetCode Solution114
1245Check for Identical BSTs without building the trees114
1246Find Minimum in Rotated Sorted Array II LeetCode Solution114
1247Find minimum number of merge operations to make an array palindrome114
1248Longest Common Prefix Using Word by Word Matching114
1249Graph Cloning114
1250Contiguous Array114
1251Find k-th smallest element in BST (Order Statistics in BST)114
1252Check if each internal node of a BST has exactly one child114
1253Merge k Sorted Lists Leetcode Solution113
1254Maximum Product Subarray113
1255Largest Plus Sign Leetcode Solution113
1256Print Ancestors of a Given Binary Tree Node Without Recursion113
1257Print n terms of Newman-Conway Sequence112
1258Symmetric Tree LeetCode Solution Leetcode Solution112
1259Check if two nodes are on the same path in a Tree112
1260Image Overlap LeetCode Solution112
1261Count and Toggle Queries on a Binary Array111
1262Minimum Remove to Make Valid Parentheses LeetCode Solution111
1263Excel Sheet Column Title LeetCode Solution111
1264Verify Preorder Serialization of a Binary Tree111
1265Smallest Range II Leetcode Solution110
1266Minimum Time to Collect All Apples in a Tree LeetCode Solution110
1267Number of elements less than or equal to a given number in a given subarray110
1268Check If a String Can Break Another String Leetcode Solution109
1269Next greater element109
1270Palindrome Partitioning109
1271Min Cost Climbing Stairs LeetCode Solution108
1272Orderly Queue LeetCode Solution108
1273Different Ways to Add Parentheses Leetcode Solution107
1274Koko Eating Bananas LeetCode Solution107
1275Check in binary array the number represented by a subarray is odd or even106
1276Largest Submatrix With Rearrangements LeetCode Solution106
1277Peeking Iterator LeetCode Solution106
1278Longest Substring Without Repeating Characters Leetcode Solution106
1279Merge Sorted Array105
1280Newman–Shanks–Williams prime105
1281Check if X can give change to every person in the Queue105
1282Range Minimum Query (Square Root Decomposition and Sparse Table)104
1283Queries for Decimal Values of Subarrays of a Binary Array104
1284Maximum Sum Increasing Subsequence102
1285Arranging Coins Leetcode Solution102
1286Find maximum average subarray of k length102
1287Array Nesting Leetcode Solution102
1288Number of indexes with equal elements in given range102
1289Maximum product of an increasing subsequence102
1290Encoded String With Shortest Length LeetCode Solution102
1291Check given array of size n can represent BST of n levels or not101
1292Convert a BST to a Binary Tree such that sum of all greater keys is added to every key100
1293Find the Winner of the Circular Game LeetCode Solution99
1294Minimum Number of People to Teach LeetCode Solution99
1295Minimum Total Space Wasted With K Resizing Operations LeetCode Solution99
1296Convert to Base -2 LeetCode Solution99
1297Binary Tree to Binary Search Tree Conversion using STL set98
1298Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution98
1299Continuous Subarray Sum LeetCode Solution98
1300Random Pick Index LeetCode Solution98
1301Jump Game IV LeetCode Solution98
1302Reach a Number LeetCode Solution97
1303Vertical Order Traversal of Binary Tree LeetCode Solution97
1304Add Two Numbers II Leetcode Solution97
1305Queries on XOR of greatest odd divisor of the range96
1306Insert Delete GetRandom O(1) Leetcode Solution95
1307Palindrome Number LeetCode Solution95
1308Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution95
1309Design Underground System Leetcode Solution91
1310Shifting Letters LeetCode Solution90
1311Print Maximum Length Chain of Pairs89
1312Detect Capital Leetcode Solution88
1313Design A Leaderboard Leetcode Solution88
1314Substring with Concatenation of All Words Leetcode Solution85
1315Minimum Swaps to Group All 1’s Together Leetcode Solution84
1316Count Sub Islands LeetCode Solution83
1317Top K Frequent Elements LeetCode Solution83
1318Minimum Path Sum Leetcode Solution82
1319Binary Tree Inorder Traversal LeetCode Solution81
1320Odd Even Linked List Leetcode Solution79
1321Longest Common Subsequence LeetCode Solution78
1322Decode String Leetcode Solution78
1323Maximum Population Year LeetCode Solution78
1324Best Meeting Point LeetCode Solution77
1325Find the Town Judge LeetCode Solution77
1326Shortest Unsorted Continuous Subarray LeetCode Solution76
1327Find the Town Judge LeetCode Solution76
1328Sum Root to Leaf Numbers LeetCode Solution75
1329Rectangle Overlap LeetCode Solution72
1330Maximum Population Year LeetCode Solution71
1331Design Add and Search Words Data Structure LeetCode Solution71
1332Flatten Binary Tree to Linked List LeetCode Solution69
1333Stone Game IV LeetCode Solution68
1334Score of Parenthesis LeetCode Solution68
1335Insert into a Sorted Circular Linked List LeetCode Solution68
1336Range Sum Query 2D – Immutable LeetCode Solution66
1337Reveal Cards In Increasing Order Leetcode Solution65
1338Valid Triangle Number LeetCode Solution64
1339Is Graph Bipartite? LeetCode Solution64
1340Divide Chocolate LeetCode Solution57
1341Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution53
1342Reverse Integer Leetcode Solution47
1343Range Sum of BST LeetCode Solution46
1344Sort Colors LeetCode Solution43
1345Find K Closest Elements LeetCode Solution43
1346Rotate String LeetCode Solution40
1347Maximum Side Length of a Square with Sum Less than or Equal to Threshold LeetCode Solution40
1348Excel Sheet Column Number LeetCode Solution39
1349H-Index Leetcode Solution20
1350Maximum Size Subarray Sum Equals k Leetcode Solution20
1351High Five LeetCode Solution19
1352Camelcase Matching Leetcode Solution18
1353Monotonic Array Leetcode Solution16
1354Group Shifted Strings Leetcode Solution14
1355Valid Anagram Leetcode Solution14
1356Peak Index in a Mountain Array LeetCode Solution12
1357Insert Delete GetRandom O(1) – Duplicates allowed LeetCode Solution12
1358Unique Binary Search Trees LeetCode Solution11
1359Pairs of Songs With Total Durations Divisible by 60 LeetCode Solution11
1360Next Greater Element I Leetcode Solution11
1361Next Permutation LeetCode Solution11
1362Closest Binary Search Tree Value II LeetCode Solution10
1363Valid Triangle Number LeetCode Solution10
1364Flatten Binary Tree to Linked List LeetCode Solution10
1365Minimum Number of Arrows to Burst Balloons LeetCode Solution10
1366Isomorphic Strings LeetCode Solution9
1367Paint House LeetCode Solution9
1368Sentence Screen Fitting LeetCode Solution8
1369Swim in Rising Water LeetCode Solution7
1370Container With Most Water LeetCode Solution3
Translate »