Minimum Number of Arrows to Burst Balloons LeetCode Solution

Difficulty Level Medium
Frequently asked in Amazon Apple Bloomberg Facebook Flipkart Goldman Sachs Google Microsoft Swiggy Uber
Walmart Global techViews 1

Problem Statement:

Minimum Number of Arrows to Burst Balloons LeetCode Solution: 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 up directly vertically (in the positive y-direction) from different points along the x-axis. A balloon with xstart and xend is burst by an arrow shot at x if xstart <= x <= xend. There is no limit to the number of arrows that can be shot. A shot arrow keeps traveling up infinitely, bursting any balloons in its path.

Given the array points, return the minimum number of arrows that must be shot to burst all balloons.

Examples:

Example 1:

Input:

 points = [[10,16],[2,8],[1,6],[7,12]]

Output:

 2

Explanation:

 The balloons can be burst by 2 arrows:
- Shoot an arrow at x = 6, bursting the balloons [2,8] and [1,6].
- Shoot an arrow at x = 11, bursting the balloons [10,16] and [7,12].

Example 2:

Input:

 points = [[1,2],[3,4],[5,6],[7,8]]

Output:

 4

Explanation:

 One arrow needs to be shot for each balloon for a total of 4 arrows.

Example 3:

Input:

 points = [[1,2],[2,3],[3,4],[4,5]]

Output:

 2

Explanation:

 The balloons can be burst by 2 arrows:
- Shoot an arrow at x = 2, bursting the balloons [1,2] and [2,3].
- Shoot an arrow at x = 4, bursting the balloons [3,4] and [4,5].

Approach:

Idea:

The problem can be solved with the help of sorting. We will sort all the balloons based on their first index. Starting from the first balloon we will iterate over the entire list. At each iteration, we will check whether the balloon can be burst with the current arrow or not by checking if its end is within the range or not. If yes, we will reassign the top with the minimum value, else if no, then we will assign a new arrow for the current balloon. Check out the code for a better understanding.

Given the array points, return the minimum number of arrows that must be shot to burst all balloons.Pin

Code:

Minimum Number of Arrows to Burst Balloons C++ Solution:

class Solution {
public:
    int findMinArrowShots(vector<vector<int>>& points) {
        int n=points.size();
        sort(points.begin(),points.end());

        int ans=1;
        int top = points[0][1];
        for(int i=1;i<n;i++){
            if(points[i][0]<=top){
                top = min(top,points[i][1]);
            }
            else{
                top=points[i][1];
                ans++;
            }
        }
        return ans;
    }
};

Minimum Number of Arrows to Burst Balloons Python Solution:

class Solution:
    def findMinArrowShots(self, points: List[List[int]]) -> int:
        n = len(points)
        points.sort()

        ans = 1
        top = points[0][1]
        for i in range(1,n):
            if points[i][0]<=top:
                top = min(top,points[i][1])
            else:
                top=points[i][1]
                ans += 1
        return ans

Complexity Analysis of Minimum Number of Arrows to Burst Balloons LeetCode Solution:

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 Tree2509
3Reverse a string without affecting special characters2470
4Delete a node of a linked list at given position1983
5Palindrome using Recursion1884
6Insert nodes in a linked list in a sorted way (Ascending Order)1668
7Find elements pair from array whose sum equal to number1655
8Sort Elements by Frequency of Occurrences1641
9Quick Sort1627
10Write a program to print all permutations of a given string1615
11Find Minimum Distance Between Two Numbers in an Array1479
12Create a Doubly Linked List1455
13Reverse an Array1417
14Smallest window in a string containing all characters of another string1402
15Find a Triplet That Sum to a Given Value1365
16Recursively remove all adjacent duplicates1363
17First Repeating Element1346
18Arrange Even and Odd number such that Odd comes after Even1328
19Sum of numbers in String1324
20Smallest Positive Number Missing in an Unsorted Array1292
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 List1225
25Subarray with Given Sum1217
26Print all Possible Combinations of R Elements in a given Array of size N1210
27Recursive function to do substring search1206
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 identical1112
32Maximum Subarray Sum using Divide and Conquer1110
33Remove characters from first string which are in second1077
34Find Leaders in an Array1065
35Swap nodes in the linked list1044
36Find the Number Occurring Odd Number of Times in an Array1009
37Find the second most frequent character997
38Arrange given Numbers to Form the Biggest Number II997
39Given a string find its first non-repeating character976
40Find Triplet in Array With a Given Sum968
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 not956
44Print all possible words from phone digits940
45Find the Missing Number932
46Rearrange Positive and Negative Numbers Alternatively in Array926
47Longest Palindromic Substring910
48Segregate even and odd nodes in a linked list893
49Print Longest common subsequence889
50Union and Intersection of Two Linked Lists880
51Transform one string to another using minimum number of given operations874
52Check rearranged string can form a palindrome857
53Rearrange given Array in Maximum Minimum Form852
54Iterative Implementation of Quick Sort841
55Count Possible Triangles828
56Multiplication of Two Matrices809
57Check if the linked list is palindrome803
58Count of Triplets With Sum Less than Given Value802
59Rotate a Linked List801
60Stock Buy Sell to Maximize Profit797
61Insertion Sort773
62Concatenation of two strings768
63Tug of War767
64Count Number of Substrings with K Distinct Character’s763
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 Variable738
70Remove ‘b’ and ‘ac’ from a given string738
71Find all Common Elements in Given Three Sorted Arrays735
72Remove all duplicates in an unsorted linked list716
73Find the Row with Maximum Number of 1’s712
74Find the Peak Element from an Array705
75Find the subarray whose sum is equal to a given number X705
76Remove Minimum Characters so that Two Strings Become Anagrams697
77Addition of Two Matrices692
78Find Smallest Missing Number in a Sorted Array691
79A Product Array Puzzle689
80Generate all Binary Strings Without Consecutive 1’s685
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 Identical653
86Multiplication of Previous and Next653
87Subtraction of Two Matrices642
88Merge K Sorted Arrays and Print Sorted Output639
89Move All the Zeros to the End of the Given Array637
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’s628
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 Sum616
97Sort a stack using a temporary stack614
98Move last element of the Linked List at first place610
99Find the Minimum Element in a Sorted and Rotated Array610
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 list599
105Maximum Element in an Array which is Increasing and then Decreasing598
106Palindrome Permutations of a String594
107Elements Appear more than N/K times in Array588
108Palindromes in a given range585
109Print all permutations with repetition583
110Majority Element582
111Run length encoding582
112Minimum insertions to form a shortest palindrome580
113Pangram Checking580
114Minimum Characters to be Added at Front to Make String Palindrome572
115Rearrange a given linked list in-place572
116Remove all duplicates in a sorted linked list571
117Merge a linked list into another at alternate positions570
118Most repeating character in a string569
119Rotate string to get lexicographically minimum string568
120Minimum number of Merge Operations to make an Array Palindrome567
121Repeated Subsequence of Length Two or More565
122Print all anagrams together in a sequence of words560
123Reorder an Array According to the Given Indexes557
124Pancake Sorting Problem548
125Two Sum Leetcode Solution545
126Merge Overlapping Intervals II544
127Clone a Linked List with next and random pointer543
1283Sum Leetcode Solution542
129Transpose of a Matrix533
130Size of The Subarray With Maximum Sum533
131Remove Extra Spaces from a String530
132Removing Spaces from a String using stringstream528
133Check if a given string is a rotation of a palindrome526
134Remove duplicates from a string526
135Longest Palindrome can be Formed by Removing or Rearranging Characters525
136Partition Problem524
137Smallest Palindrome after Replacement524
138Maximum Sum Increasing Subsequence523
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 Maximized507
143Insert Node in the Sorted Linked List507
144Delete Last Occurrence505
145Check if Two given Strings are Isomorphic to each other501
146Maximum difference between two elements such as larger element comes after smaller494
147Program to Toggle all Characters in a String493
148Given string is interleaving of two other strings or not489
149Count Minimum Steps to Get the given Array486
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 Other479
155Find nth node of the Linked list from the end476
156Longest Common Prefix using Divide and Conquer476
157Sort 0s 1s and 2s in an Array468
158Print all interleavings of given two strings467
159Find a Fixed Point in a Given Array467
160Compare Two Version Numbers465
161Reverse words in a given string462
162Merge two sorted linked lists such that merged list is in reverse order462
163Find the Subarray of given length with Least Average461
164Reorder Array Using Given Indexes460
165Print Reverse of a string (Recursion)459
166Median of Two Sorted Arrays LeetCode Solution459
167Split linked list using alternate nodes458
168Print string of odd length in ‘X’ format445
169Print all Palindromic Partitions of a String441
170Swap Kth Node from beginning with Kth Node from End440
171Find K Length Subarray of Maximum Average440
172Find Element Using Binary Search in Sorted Array439
173Find Duplicates in an Array in Most Efficient Way433
174print all palindromic partitions426
175Flatten a multilevel linked list424
176Shortest Superstring Problem421
177Maximum Length of Chain Pairs421
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 II395
187Find the two Numbers with Odd Occurrences in an Unsorted Array394
188Reverse a Singly Linked List (Iterative/Non-Recursive)393
189Caesar Cipher389
190Kth Non-repeating Character388
191Rearrange a linked list in Zig-Zag386
192Check if String can Become Empty by Recursively Deleting given Substring384
193Longest Common Prefix Word by Word Matching381
194Pancake Sorting380
195Rotate Image by 90 degrees380
196Permutations of a Given String Using STL373
197Perfect Reversible String372
198Merging Two Sorted Arrays368
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 the point where a monotonically increasing function becomes positive first time366
203Find First non-repeating character in a string366
204Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes366
205Four Elements that Sum to Given363
206List items containing all characters of a given word360
207Delete N nodes after M359
208Count Number of Occurrences in a Sorted Array354
209Longest Common Prefix using Character by Character Matching354
210Palindrome string (number)350
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
215Print All Distinct Elements of the Array339
216Sorting the array of strings338
217Maximum occurring character in a string336
218Even Substring Count336
219Convert a String that is Repetition of a Substring of Length K335
220Valid Parentheses LeetCode Solution334
221Reverse a singly linked list recursively333
222Find the first Repeating Number in a Given Array333
223Print Shortest Path to Print a String on Screen331
224Binary Tree to Doubly linked list329
225Can we reverse a linked list in less than O(n) time ?329
226Nth Character in Concatenated Decimal String328
227Convert string1 to string2 in one edit327
228Reverse a String using Stack326
229wildcard character matching325
230Sort Elements by Frequency II325
231Lower Case To Upper Case323
232Maximum Subarray Leetcode Solution323
233Count the number of words318
234Merge Two Sorted Arrays318
235Split Four Distinct Strings316
236Find the Lost Element From a Duplicated Array315
237Find middle of the Linked List312
238Longest Common Subsequence with Permutations309
239Count the Pairs at Same Distance as in English Alphabets308
240Matrix Chain Multiplication using Dynamic Programming307
241Next Greater Element in an Array303
242Palindrome Permutation298
243Roman to Integer Leetcode Solution293
244Find Nth Node292
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 value284
250Reverse a String283
251Word Search Leetcode Solution283
252Reverse Bits282
253Print all Possible Ways to Break a String in Bracket Form281
254Delete a node under given conditions280
255Change Gender of a given String278
256Binary Tree278
257Sort an array of strings277
258How to Efficiently Implement k Stacks in a Single Array?277
259Count Pairs With Given Sum275
260First non Repeating Element274
261Meeting Rooms II LeetCode Solution273
262Number of sub-strings which recursively add up to 9273
263Toeplitz Matrix273
264Repeated Substring Pattern272
265Longest Common Extension271
266Remove middle points in a linked list of line segments270
267Move all negative elements to one side of array270
268N queen problem269
269Remove spaces from a string268
270Longest Palindromic Substring LeetCode Solution266
271Shuffle a given Array264
272Min Stack263
273Number of Islands LeetCode Solution260
274Dijkstra Algorithm259
275Cuckoo sequence program259
276House Robber Leetcode Solution258
277Max stack258
278Find, second, frequent, character257
279Most Frequent Element in an Array256
280Fibonacci numbers254
281Minimize the maximum difference between the heights254
282Clone a linked list with next and random pointer (Hashing)252
283Search Insert Position Leetcode Solution251
284Expression Evaluation250
285Sort linked which is sorted on absolute values250
286Subset Leetcode249
287Sudoku Solver249
288Valid Palindrome Leetcode Solution248
289Plus One Leetcode Solution247
290KMP Algorithm247
291Number Of 1 bits246
292Word Search246
293Evaluation of Postfix Expression246
294Combination Sum Leetcode Solution245
295Reverse words in a string245
296How to Delete a Linked List245
297Min Stack Leetcode Solution244
298Backspace String Compare241
299Set Matrix Zeroes238
300Rabin Karp Algorithm237
301Pair of Positive Negative Values in an Array236
302Sqrt(x) Leetcode Solution236
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
310Contains Duplicate II Leetcode Solution230
311Product of array except self230
312Integer to Roman Leetcode Solution230
313String Compression228
314Intersection of Two Arrays II Leetcode Solution228
315Pascal Triangle Leetcode228
316Reverse individual words226
317Minimum swaps required to bring all elements less than or equal to k together225
318Construct Binary Tree from Given Inorder and Preorder Traversals225
319Count of index pairs with equal elements in an array225
320Segregate even and odd numbers225
321Count subarrays with equal number of 1’s and 0’s225
322Add Binary Leetcode Solution224
323Bellman Ford Algorithm224
324Implementation of Deque using Doubly Linked List224
325Find Top K (or Most Frequent) Numbers in a Stream224
326Sliding Window Technique223
327Minimum Value to Get Positive Step by Step Sum Leetcode Solution223
328Single Number Leetcode Solution223
329Contains Duplicate222
330Sort elements by frequency221
331Palindrome Linked List Leetcode Solution221
332Arithmetic Expression Evaluation221
333Second Most Repeated Word in a Sequence221
334Find sum of non-repeating elements (distinct) elements in an array220
335Pow(x, n) Leetcode Solution219
336Page Replacement Algorithms in Operating Systems219
337Postfix to Infix Conversion219
338Count Odd Numbers in an Interval Range Leetcode Solution219
339Group Words With Same Set of Characters218
340Maximum Number of Balloons Leetcode Solution218
341Design a stack that supports getMin() in O(1) time and O(1) extra space218
342Next Permutation218
343Kruskal Algorithm217
344Longest Common Prefix Leetcode Solution216
345Sum of minimum and maximum elements of all subarrays of size k216
346Smallest Subarray with k Distinct Numbers216
347Scramble String215
348Third Maximum Number Leetcode Solution215
349Maximum Subarray215
350Find Lucky Integer in an Array Leetcode Solution215
351K-th Smallest Element in a Sorted Matrix214
352Convex Hull Algorithm214
353Top K Frequent Words214
354Permutations Leetcode Solution214
355Longest Substring Without Repeating Characters LeetCode Solution214
356Find the Town Judge Leetcode Solution213
357Sorting array using Stacks212
358Minimum operation to make all elements equal in array212
359Find Numbers with Even Number of Digits Leetcode Solution212
360Count subarrays having total distinct elements same as original array212
361Number of Good Pairs Leetcode Solution210
362Majority Element Leetcode Solution210
363Special Number210
364Evaluate Division210
365Swap Nodes in Pairs Leetcode Solutions209
366Spiral Matrix LeetCode Solution209
367Given two unsorted arrays find all pairs whose sum is x209
368First element occurring k times in an array209
369Prefix to Infix Conversion208
370Huffman Coding207
371Check if two arrays are equal or not207
372Count Primes Leetcode Solutions207
373Merge Two Sorted Lists Leetcode Solutions207
374Minimum Path Sum207
375Best Time to Buy and Sell Stock  II Leetcode Solution206
376Reverse a Number Using Stack206
377Single Number206
378Reversing the First K elements of a Queue206
379Missing Number Leetcode Solution206
380Pascal’s Triangle II Leetcode Solution206
381Maximal Square205
382Search in Rotated Sorted Array Leetcode Solution205
383Minimum Absolute Difference Leetcode Solution205
384Minimum Steps to reach target by a Knight205
385Group Anagrams205
386Sort Array by Increasing Frequency Leetcode Solution204
387House Robber II Leetcode Solution204
388Find duplicates in a given array when elements are not limited to a range204
389Maximum Distance Between two Occurrences of Same Element in Array203
390Running Sum of 1d Array Leetcode Solution203
391Power of Two Leetcode Solution203
392Find the first repeating element in an array of integers202
393How to Implement Stack Using Priority Queue or Heap?202
394Convert String To Int202
395Palindrome Substring Queries202
396Top K Frequent Elements202
397Find Minimum In Rotated Sorted Array202
398Find All Numbers Disappeared in an Array Leetcode Solution202
399Matrix Diagonal Sum Leetcode Solution202
400Check if Array Contains Contiguous Integers With Duplicates Allowed201
401Expression Contains Redundant Bracket or Not201
402Fizz Buzz Leetcode201
403Unique Paths Leetcode Solution201
404Unique Paths201
405Subarray Sum Equals k201
406Zigzag Conversion201
407Maximum possible difference of two subsets of an array201
408Find the Closest Palindrome number201
409Sorting using trivial hash function201
410Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution200
411Sort Integers by The Number of 1 Bit Leetcode Solution200
412How Many Numbers Are Smaller Than the Current Number Leetcode Solution200
413Smallest Element Repeated Exactly K Times200
414Range Sum Query 2D – Immutable Leetcode Solution199
415Leetcode Permutations199
416Cumulative Frequency of Count of Each Element in an Unsorted Array199
417Find Number of Employees Under every Employee199
418Max Consecutive Ones Leetcode Solution199
419Subset sum problem199
420Coin Change 2 Leetcode Solution198
421Length of the largest subarray with contiguous elements198
422Happy Number Leetcode Solution198
423Find Winner on a Tic Tac Toe Game Leetcode Solution198
424Subarray Sum Equals K LeetCode Solution197
425Print All Distinct Elements of a Given Integer Array197
426Difference between highest and least frequencies in an array197
427Sort a stack using recursion197
428Letter Case Permutation197
429Implement Stack and Queue using Deque197
430Decode String197
431Reverse Integer197
432Find top three repeated in array197
433Fibonacci Number LeetCode Solution196
434Best Time to Buy and Sell Stock III Leetcode Solution196
435LRU Cache Implementation196
436Nth Catalan Number196
437Remove Duplicates from Sorted Array Leetcode Solution196
438Print all subarrays with 0 sum196
439Monotonic Array LeetCode Solution196
440Count Substrings with equal number of 0s, 1s and 2s195
441Sum of Subarray Ranges Leetcode Solution195
442Capacity To Ship Packages Within D Days Leetcode Solution194
443Check If N and Its Double Exist Leetcode Solution194
444Find The Duplicate Number194
445Generate a String With Characters That Have Odd Counts Leetcode Solution194
446Maximum Depth of Binary Tree Leetcode Solution194
447Reverse Vowels of a String Leetcode Solution194
448Reverse a Stack Using Recursion194
449Subarrays with distinct elements194
450Kth largest element in an Array Leetcode Solutions193
451Reverse Words in a String III LeetCode Solution193
452Merge Two Sorted Linked Lists193
453Subtract the Product and Sum of Digits of an Integer Leetcode Solution193
454Integer to English words193
455Find Median from data Stream193
456Find the Duplicate Element192
457Prim’s Algorithm192
458Bipartite Graph192
459Shuffle the Array Leetcode Solution192
460Delete a Node from linked list without head pointer192
461Trapping Rain Water Leetcode Solution192
462Longest Common Subsequence191
463Target Sum191
464Reverse a String191
465Find the Difference Leetcode Solution191
466Remove Minimum Number of Elements Such That no Common Element Exist in both Array191
467Count and Say191
468Edit Distance190
469Count pairs from two linked lists whose sum is equal to a given value190
470Find all pairs (a, b) in an array such that a % b = k190
471Sorting a Queue without Extra Space190
472Iterative Tower of Hanoi190
473Priority Queue Using Singly Linked List190
474Find Common Characters Leetcode Solution190
475Excel Sheet Column Number Leetcode Solution190
476Balanced Binary Tree Leetcode Solution190
477Find elements which are present in first array and not in second190
478Floyd Warshall Algorithm189
479Longest Common Prefix using Trie189
480Concatenation of Array LeetCode Solution189
481The K Weakest Rows in a Matrix Leetcode Solution189
482Text Justification LeetCode Solution189
483Fizz Buzz189
484Kids With the Greatest Number of Candies Leetcode Solution188
485Reverse a linked list188
486Minimum Moves to Equal Array Elements Leetcode Solution188
487Design Parking System Leetcode Solution188
488Find First and Last Position of Element in Sorted Array Leetcode Solution188
489Degree of an array188
490Next Greater Element I Leetcode Solution188
491Prefix to Postfix Conversion187
492Kth Largest Element in a Stream Leetcode Solution187
493Merge Overlapping Intervals187
494Number of Steps to Reduce a Number to Zero Leetcode Solution187
495Top View of Binary Tree187
496Flood Fill LeetCode187
497Word Ladder LeetCode Solution187
498Valid Parenthesis String187
499Longest subarray not having more than K distinct elements187
500MiniMax Algorithm187
501Find subarray with given sum (Handles Negative Numbers)186
502Zigzag Conversion LeetCode Solution186
503Shortest Palindrome186
504Find four elements that sum to a given value (Hashmap)186
505Slowest Key Leetcode Solution186
506Pair with given product186
507Multiply Strings Leetcode Solution186
508Count and Say Leetcode Solution185
509Priority Queue in C++185
510Convert array into Zig-Zag fashion185
511The Stock Span Problem185
512Max Area of Island185
513Postfix to Prefix Conversion185
514Jump Game Leetcode Solution185
515Find N Unique Integers Sum up to Zero Leetcode Solution185
516Implement a stack using single queue184
517Recursion184
518Mobile Numeric Keypad Problem184
519Length of Last Word Leetcode Solution184
520Substring With Concatenation Of All Words184
521Find Index of Closing Bracket for a Given Opening Bracket in an Expression184
522Move Zeroes LeetCode Solution184
523Find any one of the multiple repeating elements in read only array184
524Peak Index in a Mountain Array183
525Next Greater Frequency Element183
526Shuffle String Leetcode Solution183
527Count number of triplets with product equal to given number183
528Check if a given array contains duplicate elements within k distance from each other183
529Find distinct elements common to all rows of a matrix183
530Intersection of Two Arrays182
531Longest Common Prefix using Sorting182
532Implement Stack using Queues182
533Rearrange a binary string as alternate x and y occurrences182
534Iterative Inorder Traversal of a Binary Tree182
535Largest Sum Contiguous Subarray182
536Find missing elements of a range182
537Smallest Subarray With all Occurrences of a Most Frequent Element181
538Last Stone Weight181
539Convert a normal BST to Balanced BST181
540Excel Sheet Column Title Leetcode Solution181
541Relative Sort Array Leetcode Solution181
542Delete Node in a Linked List Leetcode Solution181
543Contiguous Array Leetcode181
544Koko Eating Bananas Leetcode Solution180
545Group Multiple Occurrence of Array Elements Ordered by first Occurrence180
546Valid Sudoku180
547Change the Array into Permutation of Numbers From 1 to N180
548First negative integer in every window of size k179
549N-th Tribonacci Number Leetcode Solution179
550Isomorphic Strings Leetcode Solution179
551Distribute Candies to People Leetcode Solution179
552Is Subsequence Leetcode Solution179
553Best Time to Buy and Sell Stock179
554Container with Most Water179
555Minimum Bracket Reversals179
556K-th Distinct Element in an Array179
557Linked List Cycle II LeetCode Solution179
558Number of Provinces Leetcode Solution178
559Assign Cookies Leetcode Solution178
560Jewels and Stones Leetcode Solution178
561Integer to Roman178
562Minimum Delete Operations to make all Elements of Array Same178
563Sum of Left Leaves Leetcode Solutions178
564Find Words That Can Be Formed by Characters Leetcode Solution178
565Implementation of Deque using circular array178
566Minimum Operations to convert X to Y178
567Gold Mine Problem177
568Convert Sorted Array to Binary Search Tree Leetcode Solution177
569Minimum Knight Moves LeetCode Solution177
570Summary Ranges Leetcode Solution177
571Build Array From Permutation Leetcode Solution177
572Shuffle an Array177
573Unique Binary Search Trees177
574Valid Anagrams177
575Check for Balanced Parentheses in an Expression177
576Largest Perimeter Triangle Leetcode Solution177
577Island Perimeter Leetcode Solution177
578Arrange given numbers to form the biggest number177
579Remove Linked List Elements Leetcode Solution176
580LRU Cache LeetCode Solution176
581Hamming Distance176
582Maximum path sum in a triangle176
583Combinations Leetcode Solution176
584Trapping Rain Water LeetCode Solution176
585Maximum sum rectangle in a 2D matrix176
58601 Matrix LeetCode Solution176
5873Sum Closest LeetCode Solution175
588Count all subsequences having product less than K175
589Decode Ways175
590Count the number of nodes at given level in a tree using BFS175
591The Knapsack Problem175
592Rotate List Leetcode Solution175
593Find the smallest positive integer value that cannot be represented as sum of any subset of a given array175
594Minimum insertions to form a palindrome with permutations allowed174
595Shortest Path in a Grid with Obstacles Elimination LeetCode Solution174
596Minimum number of subsets with distinct elements174
597Find minimum difference between any two elements173
598Maximum Distance in Array173
599Minimum number of distinct elements after removing m items173
600Maximum Number of Chocolates to be Distributed Equally Among k Students173
601Insert Interval Leetcode Solution173
602Same Tree LeetCode Solution173
603Distance Between Bus Stops Leetcode Solution173
604Bubble sort using two Stacks173
605Rotate Image LeetCode Solution172
606Painting Fence Algorithm172
607Find if an Expression has Duplicate Parenthesis or Not172
608Longest Increasing Subsequence172
609Stone Game LeetCode172
610Sieve of Eratosthenes172
611How to check if two given sets are disjoint?172
612Sort Characters By Frequency LeetCode Solution172
613XOR Operation in an Array Leetcode Solution172
614Applications of Breadth First Search and Depth First Search171
615Reverse a stack without using extra space in O(n)171
616Word Pattern171
617License Key Formatting Leetcode Solution171
618Replace Elements with Greatest Element on Right Side Leetcode Solution171
619Permutation in String Leetcode Solution171
620Find Sum of all unique sub-array sum for a given array171
621Defanging an IP Address Leetcode Solution171
622Frog Jump Leetcode Solution171
623K Empty Slots LeetCode170
624Minimum Cost to Hire K Workers170
625Word Wrap Problem170
626Smallest Good Base170
627Find the Duplicate Number LeetCode Solution170
628Remove All Occurrences of a Substring LeetCode Solution170
629House Robber170
630Sort Array By Parity LeetCode Solution170
631Distance of nearest cell having 1 in a binary matrix169
632Best Time to Buy and Sell Stock LeetCode Solution169
633Optimal Account Balancing LeetCode Solution169
634Tracking current Maximum Element in a Stack169
635Longest Substring with At Least K Repeating Characters LeetCode Solution169
636Isomorphic Strings169
637Non-overlapping sum of two sets169
638Maximum Consecutive Numbers Present in an Array169
639Minimum Depth of Binary Tree Leetcode Solution169
640Segregate 0s and 1s in an Array169
641Printing brackets in Matrix Chain Multiplication Problem169
642Kth Missing Positive Number Leetcode Solution168
643Iterative Method to find Height of Binary Tree168
644Employee Free Time LeetCode Solution168
645Moving Average from Data Stream Leetcode Solution168
646Merge Two Balanced Binary Search Trees168
647Valid Palindrome II Leetcode Solution168
648Wiggle Sort168
649Binary Tree Zigzag Level Order Traversal LeetCode Solution168
650Coin Change Problem168
651Longest Substring with At Most K Distinct Characters LeetCode Solution168
652Maximum difference between first and last indexes of an element in array167
653Queries for counts of array elements with values in given range167
654Path With Maximum Minimum Value LeetCode Solution167
655Reorganize String167
656Sum of All Odd Length Subarrays Leetcode Solution167
657Check If It Is a Straight Line Leetcode Solution167
658Find Maximum Level sum in Binary Tree167
659Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions167
660Count Good Nodes in Binary Tree Leetcode Solution167
661How to Create Mergable Stack?167
662Find Largest d in Array such that a + b + c = d166
663Strobogrammatic Number LeetCode Solution166
664Flipping an Image LeetCode Solution166
665Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest166
666Find the Distance Value Between Two Arrays Leetcode Solution166
667GCD Of Two Numbers166
668Maximum Number of Occurrences of a Substring Leetcode Solution166
669Best Time to Buy and Sell Stock with Cooldown Leetcode Solution166
670Check if a queue can be sorted into another queue using a stack165
671Find pairs with given sum such that elements of pair are in different rows165
672Valid Palindrome165
673Remove Invalid Parentheses Leetcode Solution165
674Delete consecutive same words in a sequence165
675Inorder Successor of a node in Binary Tree165
676Convert an array to reduced form165
677K Empty Slots165
678Print the Fibonacci numbers in reverse order165
679Letter Combinations of a Phone Number165
680Reducing Dishes LeetCode Solution165
681Partition Labels LeetCode Solution164
682Maximum Number of Coins You Can Get Leetcode Solution164
683Check If Two String Arrays are Equivalent Leetcode Solution164
684Number of Dice Rolls With Target Sum LeetCode Solution164
685Factorial Trailing Zeroes Leetcode Solution164
686Increasing Decreasing String Leetcode Solution164
687BFS vs DFS for Binary Tree164
688To Lower Case Leetcode Solution164
689Power of Four Leetcode Solution163
690Find Leaves of Binary Tree LeetCode Solution163
691Subset Sum Leetcode163
692Find the Smallest Divisor given a Threshold Leetcode Solution163
693Permutation Sequence LeetCode Solution163
694Valid Perfect Square Leetcode Solution163
695Recover Binary Search Tree163
696Edit Distance LeetCode Solution163
697Delete Nth node from the end of the given linked list163
698Lucky Numbers in a Matrix Leetcode Solution163
699Populating Next Right Pointers in Each Node163
700Form minimum number from given sequence163
701Longest Increasing Path in a Matrix LeetCode Solution163
702Partition Array Into Three Parts With Equal Sum Leetcode Solution163
703Reversing a Queue using Recursion162
704Binary Tree zigzag level order Traversal162
705Sort Array by Increasing Frequency Leetcode Solution162
706Dynamic Programming Basics162
707Construct BST from given Preorder Traversal162
708Ugly Number Leetcode Solution162
709Reverse Only Letters LeetCode Solution162
710Merge Two Binary Trees LeetCode Solution162
711Unique Paths II Leetcode Solution162
712Find whether an array is subset of another array162
713Maximum Product of Two Elements in an Array Leetcode Solution162
714String to Integer (atoi) LeetCode Solution162
715Add and Search Word – Data structure design LeetCode161
716Find the largest multiple of 3161
717Robot Room Cleaner Leetcode Solution161
718Binomial Coefficient161
719Decompress Run-Length Encoded List Leetcode Solution161
720Reservoir Sampling161
721Keyboard Row Leetcode Solution161
722Convert a Number to Hexadecimal Leetcode Solution161
723Finding K closest element160
724Bulb Switcher LeetCode Solution160
725Find the node with minimum value in a Binary Search Tree160
726Perform String Shifts Leetcode160
727Restore IP Addresses Leetcode Solution160
728Majority Element II Leetcode Solution160
729Find Maximum Depth of Nested Parenthesis in a String159
730Hamming Distance Leetcode Solution159
731Numbers with prime frequencies greater than or equal to k159
732Race Car LeetCode Solution159
733Sum of f(a[i], a[j]) over all pairs in an array of n integers159
734Rank Transform of an Array Leetcode Solution159
735Word Pattern LeetCode Solution159
736Find Pair with Greatest Product in Array159
737Minimum Cost For Tickets Leetcode Solution159
738Snakes and Ladders LeetCode Solution159
739Check if Two Expressions With Brackets are Same159
740Minimum Height Trees158
741Invert Binary Tree LeetCode Solution158
742Tiling Problem158
743Diagonal Traversal of Binary Tree158
744Linked List Cycle158
745Merge K Sorted Linked Lists158
746Maximum Product of Three Numbers LeetCode Solution158
747Morris Traversal158
748Student Attendance Record I Leetcode Solution158
749Generate all possible sorted arrays from alternate elements of two given sorted arrays158
750Longest Span with same Sum in two Binary arrays158
751Minimum time required to rot all oranges158
752First Unique Character in a String LeetCode Solution158
753Non-decreasing Array LeetCode Solution158
754Minimum Distance Between BST Nodes Leetcode Solution158
755Queue based approach for first non-repeating character in a stream158
756Binary Tree Maximum Path Sum LeetCode Solution158
757Number of Islands II LeetCode Solution158
758Maximum 69 Number Leetcode Solution158
759Find unique character in a string158
760Maximum Depth of N-ary Tree Leetcode Solution157
761Sorted Linked List to Balanced BST157
762Largest subarray with equal number of 0s and 1s157
763Minimize Maximum Pair Sum in Array LeetCode Solution157
764Remove Nth Node From End of List Leetcode Solution157
765Remove brackets from an algebraic string containing + and – operators157
766Best Meeting Point LeetCode Solution157
767String Compression LeetCode Solution157
768Kth ancestor of a node in binary tree157
769Find if Path Exists in Graph Leetcode Solution157
770Stack Permutations (Check if an array is stack permutation of other)157
771Find All Duplicates in an Array LeetCode Solution156
772Check If Array Pairs Are Divisible by k LeetCode Solution156
773Maximum Length of a Concatenated String with Unique Characters Leetcode Solution156
774Final Prices With a Special Discount in a Shop Leetcode Solution156
775Partition to K Equal Sum Subsets Leetcode Solution156
776Total Numbers With no Repeated Digits in a Range156
777Special Array With X Elements Greater Than or Equal X Leetcode Solution156
778Symmetric Tree Leetcode Solution156
779Jump Game156
780Largest Rectangle in Histogram LeetCode Solution156
781Elements to be added so that all elements of a range are present in array156
782Evaluate Reverse Polish Notation LeetCode Solution155
783k-th missing element in increasing sequence which is not present in a given sequence155
784Count items common to both the lists but with different prices155
785Split a String in Balanced Strings Leetcode Solution155
786Largest rectangular sub-matrix whose sum is 0155
787Search a 2D Matrix II Leetcode Solution155
788Transpose Graph155
789Program for Bridge and Torch problem155
790Find Median from Data Stream LeetCode Solution155
791Check for Palindrome after every character replacement Query154
792Growable array based stack154
793N-Queens LeetCode Solution154
794Deletion in a Binary Tree154
795Base 7 Leetcode Solution154
796Minimum Jumps to Reach Home LeetCode Solution154
797Course Schedule II – LeetCode154
798Maximum Difference Between Increasing Elements LeetCode Solution154
799Valid Number154
800Interval Tree154
801Longest Subarray Having Count of 1s One More than Count of 0s154
802Circular Queue154
803Search in a Binary Search Tree Leetcode Solution154
804Print a Binary Tree in Vertical Order154
805Sort an array according to the order defined by another array154
806Number of NGEs to the Right154
807One Edit Distance LeetCode Solution153
808Minimum number of jumps to reach end153
809String comparison containing wildcards153
810Get Maximum in Generated Array Leetcode Solution153
811Nearest Exit from Entrance in Maze LeetCode Solution153
812Minimum Time Visiting All Points Leetcode Solution153
813Spiral Matrix II Leetcode Solution153
814Nested List Weight Sum II LeetCode Solution153
815Remove Duplicates from Sorted List II153
816Reorder Data in Log Files LeetCode Solution153
817Merge Sorted Array LeetCode Solution153
818Sort Array By Parity II Leetcode Solution153
819Number Complement Leetcode Solution153
820Last Stone Weight II LeetCode Solution153
821Minimum swaps to make sequences increasing153
822Count quadruples from four sorted arrays whose sum is equal to a given value x153
823Subarray Product Less Than K LeetCode Solution152
824Maximum Profit in Job Scheduling Leetcode Solution152
825Find all triplets with zero sum152
826Relative Ranks Leetcode Solution152
827Iterative Preorder Traversal152
828A Space Optimized DP solution for 0-1 Knapsack Problem152
829Remove Duplicates from Sorted List LeetCode Solution152
830Regular Expression Matching152
831Crawler Log Folder Leetcode Solution152
832Convert BST to Min Heap152
833Priority Queue using doubly linked list152
834Maximum size subarray sum equals k152
835Form Minimum Number From Given Sequence151
836Find Maximum Sum Possible Equal Sum of Three Stacks151
837Insert into a Binary Search Tree Leetcode Solution151
838Alien Dictionary LeetCode Solution150
839Maximum Nesting Depth of the Parentheses Leetcode Solution150
840Level order Traversal in Spiral Form150
841Valid Parentheses Leetcode Solution150
842Top K Frequent Words LeetCode Solution150
843Minimum Number of Taps to Open to Water a Garden LeetCode Solution150
844Can Place Flowers LeetCode Solution150
845Sort Colors150
846Tree Traversal (Preorder, Inorder & Postorder)150
847Design a Stack With Increment Operation Leetcode Solution150
848Brick Wall LeetCode Solution150
849Partition List Leetcode Solution150
850Minimum Swaps to Make Strings Equal Leetcode Solution150
851Sum of nearest smaller and greater number150
852Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution150
853Path with maximum average value150
854Check if a given array can represent Preorder Traversal of Binary Search Tree150
855Find the subarray with least average150
856Given an Array of Pairs Find all Symmetric Pairs in it150
857Sequences of given length where every element is more than or equal to twice of previous150
858LCS (Longest Common Subsequence) of three strings150
859Binary Search Tree Search and Insertion150
860Subset with sum divisible by m150
861Friends Pairing Problem150
862Subsequence of Size K With the Largest Even Sum LeetCode Solution149
863Permutation Coefficient149
864Identify and Mark Unmatched Parenthesis in an Expression149
865Missing Element in Sorted Array LeetCode Solution149
866Guess Number Higher or Lower LeetCode Solution149
867Number of Days Between Two Dates LeetCode Solution149
868Range LCM Queries149
869Find the Only Repetitive Element Between 1 to N-1149
870Find All Possible Recipes from Given Supplies LeetCode Solution149
871Minimum Sum Path in a Triangle149
872Sorted Array to Balanced BST149
873Matrix Chain Multiplication149
874Check whether a given Binary Tree is Complete or not149
875Balanced Expression with Replacement149
876Count Distinct Elements in Every Window of Size K149
877Clone Graph LeetCode Solution149
878Brightest Position on Street LeetCode Solution149
879Count Negative Numbers in a Sorted Matrix LeetCode Solution149
880Destination City Leetcode Solution148
881Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution148
882GCDs of given index ranges in an array148
883Diagonal Traverse LeetCode Solution148
884Repeated Substring Pattern LeetCode Solution148
885Find Common Characters Leetcode Solution148
886Union and Intersection of two Linked Lists148
887An Interesting Method to generate Binary Numbers from 1 to n148
888Time Based Key-Value Store LeetCode Solution148
889Check if stack elements are pairwise consecutive148
890Range sum queries without updates148
891Count ways to reach the nth stair using step 1, 2 or 3148
892Rearrange an Array Such that arr[i] is equal to i147
893Averages of Levels in Binary Tree147
894Guess Number Higher or Lower II147
895K’th Largest Element in BST when modification to BST is not allowed147
896Find distance between two nodes of a Binary Tree147
897Three way partitioning of an array around a given range147
898Spiral Matrix III LeetCode Solution147
899Shortest Word Distance Leetcode Solution147
900Water Bottles Leetcode Solution147
901BFS for Disconnected Graph147
902Convert Sorted List to Binary Search Tree147
903Diagonal Traversal LeetCode Solution147
904Check if an Array is Stack Sortable147
905Distinct adjacent elements in an array147
906Design Browser History LeetCode Solution147
907Delete And Earn147
908Insert Delete GetRandom147
909Set Matrix Zeroes Leetcode Solution146
910Lemonade Change Leetcode Solution146
911Construct Complete Binary Tree from its Linked List Representation146
912Queue using Stacks146
913Daily Temperatures Leetcode Solution146
914Special Positions in a Binary Matrix Leetcode Solution146
915Minimum sum of multiplications of n numbers146
916Robot Bounded In Circle LeetCode Solution146
917Vertical sum in a given binary tree146
918Least Number of Unique Integers after K Removals Leetcode Solution146
919Rearrange Spaces Between Words Leetcode Solution146
920Maximum Score After Splitting a String Leetcode Solution146
921Construct the Rectangle Leetcode Solution145
922Check if the given array can represent Level Order Traversal of Binary Search Tree145
923Number of Distinct Islands Leetcode Solution145
924Dividing Array into Pairs With Sum Divisible by K145
925Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i145
926Iterative Postorder Traversal Using Two Stacks145
927Alien Dictionary145
928Find all permuted rows of a given row in a matrix145
929Maximum Subarray Sum Excluding Certain Elements144
930A program to check if a binary tree is BST or not144
931Binary Tree Longest Consecutive Sequence LeetCode Solution144
932Palindrome Partitioning Leetcode Solution144
9334Sum144
934Split Array Into Consecutive Subsequences144
935Print Fibonacci sequence using 2 variables144
9363 Sum144
937Count Subarrays with Same Even and Odd Elements144
938Construct BST from its given Level Order Traversal144
939Largest area rectangular sub-matrix with equal number of 1’s and 0’s144
940Lexicographical Numbers Leetcode Solution144
941Merge Two Sorted Lists Leetcode144
942Remove Duplicates from Sorted List II LeetCode Solution143
943Sliding Window Maximum143
944Minimum Height Trees LeetCode Solution143
945Median of Two Sorted Arrays143
946Longest Palindromic Subsequence143
947Maximum Frequency Stack Leetcode Solution143
948Stone Game II Leetcode143
949Number of Equivalent Domino Pairs Leetcode Solution143
950Three Consecutive Odds Leetcode Solution143
951Queries for GCD of all numbers of an array except elements in a given range143
952Create Maximum Number143
953Strongly Connected Component143
954Check if any two intervals overlap among a given set of intervals143
955Difference Array | Range update query in O(1)143
956Can Make Arithmetic Progression From Sequence Leetcode Solution142
957Trim a Binary Search Tree142
958Analyze User Website Visit Pattern LeetCode Solution142
959My Calendar I LeetCode Solution142
960Maximize Sum of Array after K Negations Leetcode Solution142
961Collect maximum points in a grid using two traversals142
962Infix to Postfix142
963All Unique Triplets that Sum up to a Given Value142
964Merging Intervals141
965Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space141
966Unique Paths II141
967Kth Smallest Element in a BST Leetcode Solution141
968Count Primes in Ranges141
969Find postorder traversal of BST from preorder traversal141
970Maximum Product Subarray141
971Intersection of Two Linked Lists LeetCode Solution141
972Count Submatrices With All Ones LeetCode Solution141
973Binary array after M range toggle operations141
974Minesweeper LeetCode Solution141
975Find the Difference Leetcode Solution141
976Find Maximum of Minimum for Every Window Size in a Given Array140
977Boundary Traversal of binary tree140
978The Painter’s Partition Problem140
979Climbing stairs140
980Count subarrays where second highest lie before highest140
981Height of a generic tree from parent array140
982Length of Longest Fibonacci Subsequence140
983Reverse Nodes in K-Group140
984Word Break140
985Longest Nice Substring LeetCode Solution140
986Count pair with Given Sum140
987Pattern Occurrences using Stack140
988Symmetric Tree140
989K Closest Points to Origin Leetcode Solution140
990Sign of the Product of an Array LeetCode Solution140
991Largest Substring Between Two Equal Characters Leetcode Solution139
992Product of Array Except Self LeetCode Solution139
993Largest divisible pairs subset139
994Asteroid Collision LeetCode Solution139
995Newman-Conway Sequence139
996Level Order Traversal of Binary Tree139
997Maximum length subsequence with difference between adjacent elements as either 0 or 1139
998Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution139
999Friends Of Appropriate Ages LeetCode Solution139
1000Palindrome Partitioning139
1001Binary Search Tree Delete Operation139
1002Largest Number Leetcode Solution139
1003Valid Boomerang Leetcode Solution139
1004Insertion in a Binary Tree138
1005Find Duplicate Subtrees138
1006Find number of pairs in an array such that their XOR is 0138
1007Boolean Parenthesization Problem138
1008Maximum Length of Repeated Subarray138
1009Breadth First Search (BFS) for a Graph138
1010Maximum Number of Ways to Partition an Array LeetCode Solution138
1011Segment Tree138
1012Construction of Longest Increasing Subsequence (N log N)138
1013Merge Sort138
1014Number Of Longest Increasing Subsequence138
1015Graph Valid Tree LeetCode Solution138
1016Minimum Index Sum of Two Lists138
1017The Maze III LeetCode Solution138
1018Maximum subsequence sum such that no three are consecutive138
1019Shortest Completing Word Leetcode Solution138
1020Scramble String LeetCode Solution138
1021Double the first element and move zero to end138
1022Kill Process LeetCode Solution137
1023Compute nCr % p137
1024Depth First Search (DFS) for a Graph137
1025Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’137
1026Longest subsequence such that difference between adjacents is one137
1027Ugly Numbers137
1028Construct Binary Tree from given Parent Array representation137
1029Find the First Circular Tour that visits all the Petrol Pumps137
1030Rearrange array such that even positioned are greater than odd137
1031Maximum Sum of 3 Non-Overlapping Subarrays137
1032Decrypt String from Alphabet to Integer Mapping Leetcode Solution137
1033Binary Search Tree137
1034Maximum Product of Indexes of Next Greater on Left and Right137
1035String Matching in an Array Leetcode Solution137
1036Number of palindromic paths in a matrix137
1037Next Greater Element III LeetCode Solution136
1038Serialize and Deserialize Binary Tree136
1039First missing positive136
1040Build an Array With Stack Operations Leetcode Solution136
1041Level order traversal using two Queues136
1042K maximum sums of overlapping contiguous sub-arrays136
1043Maximum weight transformation of a given string136
1044Partition Equal Subset Sum136
1045Iterative Depth First Traversal of Graph136
1046Count minimum steps to get the given desired array136
1047Make The String Great Leetcode Solution136
1048Morris Inorder Traversal136
1049Kth Smallest Element in a Sorted Matrix LeetCode Solution135
1050Available Captures for Rook Leetcode Solution135
1051Balanced Binary Tree135
1052Maximum difference between frequency of two elements such that element having greater frequency is also greater135
1053Advantages of BST over Hash Table135
1054Bitwise AND of Numbers Range LeetCode Solution135
1055Design Hit Counter LeetCode Solution135
1056Custom Sort String Leetcode Solution135
1057Invalid Transactions LeetCode Solution135
1058Add two numbers135
1059Employee Importance LeetCode Solution134
1060Path Sum II LeetCode Solution134
1061Count pairs from two sorted arrays whose sum is equal to a given value x134
1062Validate Binary Search Tree134
1063Super Ugly Number133
1064Minimum Size Subarray Sum133
1065Find a Peak Element II LeetCode Solution133
1066Implement Trie (Prefix Tree) Leetcode Solution133
1067Ugly Number II LeetCode Solution133
1068Generate Parentheses Leetcode Solution133
1069Recover Binary Search Tree Leetcode Solution133
1070Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution133
1071Defanging an IP Address LeetCode Solution133
1072Rearrange array such that even index elements are smaller and odd index elements are greater133
1073Move all negative elements to end in order with extra space allowed133
1074Lowest Common Ancestor133
1075Number of Closed Islands Leetcode Solution132
1076Populating Next Right Pointers in Each Node Leetcode Solution132
1077Regular Expression Matching Regular Expression Matching LeetCode Solution132
1078Subarrays with K Different Integers Leetcode Solution132
1079Remove Duplicates from Sorted Array II Leetcode Solution132
1080Find whether a subarray is in form of a mountain or not132
1081Binary Tree Right Side View LeetCode Solution132
1082Largest BST Subtree LeetCode Solution132
1083Find Peak Element132
1084Root to Leaf path with target sum Leetcode Solutions132
1085Search in Sorted Rotated Array132
1086Types of Binary Tree131
1087Count Largest Group Leetcode Solution131
1088Day of the Year Leetcode Solution131
1089Remove Palindromic Subsequences Leetcode Solution131
1090Number of Students Doing Homework at a Given Time Leetcode Solution131
1091Smallest Common Region Leetcode Solution131
1092Find Smallest Range Containing Elements from k Lists131
1093Longest Bitonic Subsequence131
1094Combination Sum IV LeetCode Solution131
1095Maximize Distance to Closest Person LeetCode Solution130
1096Number of siblings of a given Node in n-ary Tree130
1097Serialize and Deserialize Binary Tree LeetCode Solution130
1098Minimum Absolute Difference in BST Leetcode Solution130
1099Binary Tree Data Structure130
1100Kth Smallest Product of Two Sorted Arrays LeetCode Solution130
1101Clone a Binary Tree with Random Pointers130
1102Consecutive Characters LeetCode Solution130
1103Print all triplets in sorted array that form AP130
1104Find maximum difference between nearest left and right smaller elements129
1105Find the minimum distance between two numbers129
1106Level of Each node in a Tree from source node129
1107Cutting a Rod129
1108Next Permutation Leetcode Solution129
1109Print Next Greater Number of Q queries129
1110Palindrome Permutation LeetCode Solution129
1111Remove duplicates from sorted array129
1112Increasing Triplet Subsequence LeetCode Solution129
1113Path Sum129
1114Convert BST into a Min-Heap without using array129
1115Sum of Even Numbers After Queries129
1116Distinct Subsequences129
1117Construct K Palindrome Strings LeetCode Solution129
1118Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution128
1119Mean of Array After Removing Some Elements Leetcode Solution128
1120Find Three Element From Different Three Arrays Such That a + b + c = sum128
1121Iterative method to find ancestors of a given binary tree128
1122Valid Tic-Tac-Toe State LeetCode Solution128
1123Constant time range add operation on an array128
1124Divisible Pairs Counting128
1125Third Maximum Number Leetcode Solution128
1126Minimum sum of squares of character counts in a given string after removing k characters128
1127Maximum Product Subarray128
1128Reformat The String Leetcode Solution128
1129Bottom View of a Binary Tree128
1130Maximum Product of Splitted Binary Tree LeetCode Solution127
1131Write Code to Determine if Two Trees are Identical127
1132Products of ranges in an array127
1133Delete Nodes and Return Forest Leetcode Solution127
1134Print Right View of a Binary Tree127
1135Longest Subarray of 1’s After Deleting One Element LeetCode Solution127
1136Thousand Separator Leetcode Solution127
1137Prime Palindrome LeetCode Solution127
1138Minimum Score Triangulation of Polygon Leetcode Solution127
1139Longest Increasing Consecutive Subsequence127
1140Moser-de Bruijn Sequence126
1141Search Insert Position126
1142Find maximum length Snake sequence126
1143Search an Element in Sorted Rotated Array126
1144Swap Nodes In Pairs126
1145Cells with Odd Values in a Matrix LeetCode Solution126
1146Queries for Number of Distinct Elements in a Subarray126
1147Palindromic Substrings Leetcode Solution126
1148Subset Sum Problem in O(sum) space125
1149Merge two BSTs with limited extra space125
1150Topological Sorting125
1151Maximum Binary Tree125
1152Red-Black Tree Introduction125
1153Transform a BST to Greater sum Tree124
1154Closest Binary Search Tree Value Leetcode Solution124
1155Check Array Formation Through Concatenation Leetcode Solution124
1156Print modified array after executing the commands of addition and subtraction124
1157Priority Queue124
1158Diameter of N-Ary Tree LeetCode Solution124
1159Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution124
1160Bus Routes Leetcode Solution124
1161Maximize sum of consecutive differences in a circular array124
1162Possible Bipartition LeetCode Solution123
1163Golomb sequence123
1164Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution123
1165Decision Tree123
1166Find Largest Value in Each Tree Row LeetCode Solution123
1167Search Suggestions System LeetCode Solution123
1168Minimum Sideway Jumps LeetCode Solution123
1169Kth Smallest Number in Multiplication Table Leetcode Solution123
1170Web Crawler LeetCode Solution123
1171Minimum Moves to Equal Array Elements LeetCode Solution122
1172Minimum Cost to Move Chips to The Same Position LeetCode Solution122
1173Rotate Array122
1174K’th Largest element in BST using constant extra space122
1175Compare Strings by Frequency of the Smallest Character Leetcode Solution122
1176Count even length binary sequences with same sum of first and second half bits122
1177Find a sorted subsequence of size 3 in linear time122
1178Binary Tree to Binary Search Tree Conversion122
1179Longest Repeated Subsequence122
1180Find the smallest binary digit multiple of given number122
1181Matchsticks to Square Leetcode Solution121
1182Reverse a Path in BST using Queue121
1183Swapping Nodes in a Linked List Leetcode Solution121
1184Graph and its representation121
1185Factorial Trailing Zeroes LeetCode Solution121
1186First Bad Version121
1187Decrease Elements To Make Array Zigzag LeetCode Solution121
1188Given a binary tree, how do you remove all the half nodes?121
1189Reformat Date LeetCode Solution120
1190Queue Reconstruction by Height120
1191Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution120
1192Contiguous Array LeetCode Solution120
1193Count Pairs Whose Products Exist in Array120
1194Maximum sum of pairs with specific difference120
1195Number of Orders in the Backlog Leetcode Solution120
1196Convert Sorted Array to Binary Search Tree LeetCode Solutions120
1197Maximum number of segments of lengths a, b and c120
1198Lowest Common Ancestor in Binary Search Tree120
1199Concatenation of Array LeetCode Solution119
1200Range Queries for Longest Correct Bracket Subsequence119
1201How to print maximum number of A’s using given four keys119
1202Closest Leaf in a Binary Tree LeetCode Solution119
1203Maximum Depth Of Binary Tree119
1204Maximum sum bitonic subarray119
1205Valid Triangle Number119
1206Path Crossing Leetcode Solution119
1207Sum of Left Leaves LeetCode Solution119
1208Champagne Tower LeetCode Solution118
1209BST to a Tree with Sum of all Smaller Keys118
1210Moving Stones Until Consecutive Leetcode Solution118
1211Lowest Common Ancestor of a Binary Tree Leetcode Solution118
1212Minimum Swaps To Make Sequences Increasing LeetCode Solution118
1213Kth Smallest Element in a BST117
1214Array Queries for multiply replacements and product117
1215Divide Two Integers Leetcode Solution117
1216LRU Cache Leetcode Solution117
1217Perfect Squares LeetCode Solution117
1218Integer Break LeetCode Solution117
1219Write a function to get the intersection point of two Linked Lists117
1220Guess The Word117
1221Maximize Elements Using Another Array116
1222Mean of range in array116
1223Maximum sum of a path in a Right Number Triangle116
1224Sliding Window Median Leetcode Solution116
1225Replace two consecutive equal values with one greater116
1226Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution116
1227Maximum Value at a Given Index in a Bounded Array LeetCode Solution116
1228Flatten 2D Vector LeetCode Solution116
1229Check if all levels of two Binary Tree are anagrams or not116
1230Queries on Probability of Even or Odd Number in given Ranges116
1231Valid Perfect Square LeetCode Solution116
1232Design Skiplist LeetCode Solution115
1233Range Sum Query using Sparse Table115
1234Arithmetic Slices II – Subsequence LeetCode Solution115
1235Power of Two115
1236New 21 Game115
1237Maximum Array from Two given Arrays Keeping Order Same115
1238Graph Cloning114
1239Longest Common Prefix Using Word by Word Matching114
1240Check Completeness of a Binary Tree LeetCode Solution114
1241The kth Factor of n Leetcode Solution114
1242Check for Identical BSTs without building the trees114
1243Bold Words in String LeetCode Solution114
1244Check if each internal node of a BST has exactly one child114
1245Find Minimum in Rotated Sorted Array II LeetCode Solution114
1246Print modified array after multiple array range increment operations113
1247Count Subsets Having Distinct Even Numbers113
1248Find k-th smallest element in BST (Order Statistics in BST)113
1249Parallel Courses II LeetCode Solution113
1250Largest Plus Sign Leetcode Solution113
1251Maximum Product Subarray113
1252Contiguous Array113
1253Symmetric Tree LeetCode Solution Leetcode Solution112
1254Find minimum number of merge operations to make an array palindrome112
1255Print n terms of Newman-Conway Sequence112
1256Print Ancestors of a Given Binary Tree Node Without Recursion112
1257Missing Number111
1258Check if two nodes are on the same path in a Tree111
1259Minimum Remove to Make Valid Parentheses LeetCode Solution111
1260Merge k Sorted Lists Leetcode Solution111
1261Image Overlap LeetCode Solution111
1262Excel Sheet Column Title LeetCode Solution110
1263Number of elements less than or equal to a given number in a given subarray110
1264Count and Toggle Queries on a Binary Array110
1265Verify Preorder Serialization of a Binary Tree110
1266Smallest Range II Leetcode Solution110
1267Next greater element109
1268Orderly Queue LeetCode Solution108
1269Palindrome Partitioning108
1270Check If a String Can Break Another String Leetcode Solution108
1271Minimum Time to Collect All Apples in a Tree LeetCode Solution108
1272Koko Eating Bananas LeetCode Solution107
1273Min Cost Climbing Stairs LeetCode Solution107
1274Different Ways to Add Parentheses Leetcode Solution107
1275Check in binary array the number represented by a subarray is odd or even106
1276Longest Substring Without Repeating Characters Leetcode Solution106
1277Largest Submatrix With Rearrangements LeetCode Solution106
1278Peeking Iterator LeetCode Solution106
1279Newman–Shanks–Williams prime105
1280Check if X can give change to every person in the Queue105
1281Merge Sorted Array104
1282Queries for Decimal Values of Subarrays of a Binary Array104
1283Range Minimum Query (Square Root Decomposition and Sparse Table)103
1284Array Nesting Leetcode Solution102
1285Encoded String With Shortest Length LeetCode Solution102
1286Find maximum average subarray of k length101
1287Maximum Sum Increasing Subsequence101
1288Arranging Coins Leetcode Solution101
1289Number of indexes with equal elements in given range100
1290Check given array of size n can represent BST of n levels or not100
1291Maximum product of an increasing subsequence100
1292Convert a BST to a Binary Tree such that sum of all greater keys is added to every key100
1293Minimum Total Space Wasted With K Resizing Operations LeetCode Solution99
1294Convert to Base -2 LeetCode Solution99
1295Random Pick Index LeetCode Solution98
1296Minimum Number of People to Teach LeetCode Solution98
1297Find the Winner of the Circular Game LeetCode Solution98
1298Continuous Subarray Sum LeetCode Solution98
1299Reach a Number LeetCode Solution97
1300Jump Game IV LeetCode Solution97
1301Binary Tree to Binary Search Tree Conversion using STL set97
1302Add Two Numbers II Leetcode Solution97
1303Vertical Order Traversal of Binary Tree LeetCode Solution96
1304Queries on XOR of greatest odd divisor of the range96
1305Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution96
1306Palindrome Number LeetCode Solution95
1307Insert Delete GetRandom O(1) Leetcode Solution94
1308Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution94
1309Design Underground System Leetcode Solution90
1310Print Maximum Length Chain of Pairs89
1311Detect Capital Leetcode Solution88
1312Shifting Letters LeetCode Solution88
1313Design A Leaderboard Leetcode Solution87
1314Substring with Concatenation of All Words Leetcode Solution84
1315Minimum Swaps to Group All 1’s Together Leetcode Solution83
1316Top K Frequent Elements LeetCode Solution83
1317Count Sub Islands LeetCode Solution82
1318Minimum Path Sum Leetcode Solution81
1319Binary Tree Inorder Traversal LeetCode Solution81
1320Longest Common Subsequence LeetCode Solution78
1321Maximum Population Year LeetCode Solution77
1322Odd Even Linked List Leetcode Solution77
1323Find the Town Judge LeetCode Solution77
1324Best Meeting Point LeetCode Solution76
1325Decode String Leetcode Solution76
1326Find the Town Judge LeetCode Solution76
1327Shortest Unsorted Continuous Subarray LeetCode Solution75
1328Sum Root to Leaf Numbers LeetCode Solution74
1329Design Add and Search Words Data Structure LeetCode Solution71
1330Rectangle Overlap LeetCode Solution71
1331Maximum Population Year LeetCode Solution71
1332Flatten Binary Tree to Linked List LeetCode Solution69
1333Score of Parenthesis LeetCode Solution68
1334Stone Game IV LeetCode Solution67
1335Insert into a Sorted Circular Linked List LeetCode Solution67
1336Range Sum Query 2D – Immutable LeetCode Solution66
1337Reveal Cards In Increasing Order Leetcode Solution65
1338Valid Triangle Number LeetCode Solution64
1339Is Graph Bipartite? LeetCode Solution63
1340Divide Chocolate LeetCode Solution57
1341Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution52
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 Solution15
1354Group Shifted Strings Leetcode Solution13
1355Insert Delete GetRandom O(1) – Duplicates allowed LeetCode Solution12
1356Peak Index in a Mountain Array LeetCode Solution11
1357Unique Binary Search Trees LeetCode Solution11
1358Valid Triangle Number LeetCode Solution10
1359Isomorphic Strings LeetCode Solution9
1360Next Greater Element I Leetcode Solution9
1361Flatten Binary Tree to Linked List LeetCode Solution8
1362Swim in Rising Water LeetCode Solution7
1363Minimum Number of Arrows to Burst Balloons LeetCode Solution1
Translate »