Maximum Population Year LeetCode Solution

Difficulty Level Easy
Frequently asked in Adobe Amazon Bloomberg Cisco eBay Facebook Google Microsoft
ArrayViews 72

Problem Statement:

Maximum Population Year Leetcode Solution says that – You are given a 2D integer array logs where each logs[i] = [birthi, deathi] indicates the birth and death years of the ith person.

The population of some year x is the number of people alive during that year? The ith person is counted in the year x‘s population if x is in the inclusive range [birthi, deathi - 1]. Note that the person is not counted in the year that they die.

Return the earliest year with the maximum population.

Example:

Input:

 logs = [[1993,1999],[2000,2010]]

Output:

 1993

Explanation:

 The maximum population is 1, and 1993 is the earliest year with this population.

Approach:

Idea:

At first, the problem seems to be a bit difficult, but if you will see the constraints then we can simply brute force the solution. The idea is to check for all the possible years, i.e., find the year for which the maximum number of people were alive.

We will iterate using two loops. One will iterate over all the years ranging from 1950 to 2050 and another loop will be iterating over the logs list. For each year we will check if the current year >= log->birth and year < log->death. This way we will count the population of that year.

Code:

Leetcode Maximum Population Year C++ Solution:

class Solution {
public:
    int maximumPopulation(vector<vector<int>>& logs) {
        int ans = -1;
        int year = 0;
        for(int i=1950;i<2051;i++){
            int population = 0;
            for(int j=0;j<logs.size();j++){
                if(i>=logs[j][0] and i<logs[j][1]){
                    population++;
                }
            }
            if(population!=0 and ans<population){
                ans = population;
                year = i;
            }
        }
        return year;
    }
};

Leetcode Maximum Population Year Python Solution:

class Solution:
    def maximumPopulation(self, logs: List[List[int]]) -> int:
        ans = -1
        year = 0
        for i in range(1950,2051):
            population = 0
            for j in range(len(logs)):
                if i>=logs[j][0] and i<logs[j][1]:
                    population+=1
            if population!=0 and ans<population:
                ans = population
                year = i
        return year

 

Complexity Analysis of Maximum Population Year Leetcode Solution:

  • Time Complexity: The time complexity of the above code is O(n^2) where n in the worst case can be equal to 100. There are two inner loops and both run in O(n) time in the worst case, hence O(n^2) complexity.
  • Space Complexity: The space complexity of the above code is O(1) because we not are using any extra space. Here, we are working with variables only and we aren’t using any extra array to store any kind of information hence, space complexity remains O(1) constant extra space.

Reference: https://en.wikipedia.org/wiki/Array_data_structure

Top Interview Questions

S.No Interview Question Number of times has been asked
1Delete a node in doubly linked list2826
2Java program to find the number of Nodes in a Binary Tree2506
3Reverse a string without affecting special characters2467
4Delete a node of a linked list at given position1981
5Palindrome using Recursion1878
6Insert nodes in a linked list in a sorted way (Ascending Order)1666
7Find elements pair from array whose sum equal to number1653
8Sort Elements by Frequency of Occurrences1637
9Write a program to print all permutations of a given string1609
10Find Minimum Distance Between Two Numbers in an Array1479
11Create a Doubly Linked List1449
12Quick Sort1422
13Reverse an Array1416
14Smallest window in a string containing all characters of another string1399
15Find a Triplet That Sum to a Given Value1361
16Recursively remove all adjacent duplicates1357
17First Repeating Element1346
18Arrange Even and Odd number such that Odd comes after Even1325
19Sum of numbers in String1322
20Smallest Positive Number Missing in an Unsorted Array1289
21Check if the Elements of an Array are Consecutive1259
22Detect a loop in the Linked List1242
23Largest Sum Contiguous Subarray1233
24Quick Sort on SIngly Linked List1220
25Subarray with Given Sum1216
26Print all Possible Combinations of R Elements in a given Array of size N1207
27Recursive function to do substring search1200
28Find the Maximum Repeating Number in Array1160
29Binary Tree Level order traversal in Java1128
30Find the First and Second Smallest Elements1126
31Check if two linked lists are identical1109
32Maximum Subarray Sum using Divide and Conquer1103
33Remove characters from first string which are in second1073
34Find Leaders in an Array1064
35Swap nodes in the linked list1040
36Find the Number Occurring Odd Number of Times in an Array1008
37Arrange given Numbers to Form the Biggest Number II996
38Find the second most frequent character990
39Given a string find its first non-repeating character972
40Find Triplet in Array With a Given Sum966
41Given a sorted array and a number x, find the pair in array whose sum is closest to x956
42Total number of occurrences of a given item in the linked list956
43A Program to check if strings are rotations of each other or not949
44Print all possible words from phone digits937
45Find the Missing Number928
46Rearrange Positive and Negative Numbers Alternatively in Array925
47Longest Palindromic Substring907
48Segregate even and odd nodes in a linked list888
49Print Longest common subsequence885
50Union and Intersection of Two Linked Lists877
51Transform one string to another using minimum number of given operations872
52Check rearranged string can form a palindrome851
53Rearrange given Array in Maximum Minimum Form849
54Count Possible Triangles822
55Iterative Implementation of Quick Sort820
56Multiplication of Two Matrices805
57Check if the linked list is palindrome800
58Count of Triplets With Sum Less than Given Value795
59Stock Buy Sell to Maximize Profit795
60Rotate a Linked List795
61Concatenation of two strings766
62Tug of War763
63Print all duplicates in the input string759
64Count Number of Substrings with K Distinct Character’s758
65Find Nearest Greater and Smaller Element750
66The Celebrity Problem741
67Find Pythagorean Triplets from Array740
68Reverse String Without Temporary Variable735
69Remove ‘b’ and ‘ac’ from a given string734
70Find all Common Elements in Given Three Sorted Arrays731
71Remove all duplicates in an unsorted linked list713
72Find the Row with Maximum Number of 1’s711
73Find the Peak Element from an Array704
74Find the subarray whose sum is equal to a given number X697
75Remove Minimum Characters so that Two Strings Become Anagrams693
76Find Smallest Missing Number in a Sorted Array691
77Addition of Two Matrices689
78A Product Array Puzzle688
79Insertion Sort688
80Implement Two Stacks in an Array679
81Generate all Binary Strings Without Consecutive 1’s679
82Maximum Sum of Non Consecutive Elements671
83Maximum Product Subarray II660
84Lexicographic rank of string656
85Multiplication of Previous and Next650
86Check if Two given Matrices are Identical648
87Subtraction of Two Matrices639
88Merge K Sorted Arrays and Print Sorted Output636
89Move All the Zeros to the End of the Given Array633
90Online Algorithm for Checking Palindrome in a Stream626
91Form Minimum Number from Given Sequence of D’s and I’s626
92Divide a string in N equal parts626
93Check whether two strings are anagram of each other618
94Maximum Circular Subarray Sum615
95Remove recurring digits in a given number615
96Sort a stack using a temporary stack612
97Sort a linked list that is sorted alternating ascending and descending610
98Find the Minimum Element in a Sorted and Rotated Array608
99Move last element of the Linked List at first place604
100Subarray and Subsequence602
101First Circular Tour to Visit all the Petrol Bunks602
102Largest Subarray with Equal Number of 0’s and 1’s600
103Flattening a linked list598
104Compare two strings(linked lists)596
105Maximum Element in an Array which is Increasing and then Decreasing592
106Palindrome Permutations of a String587
107Elements Appear more than N/K times in Array584
108Majority Element581
109Palindromes in a given range580
110Run length encoding577
111Print all permutations with repetition575
112Pangram Checking573
113Minimum insertions to form a shortest palindrome573
114Merge a linked list into another at alternate positions569
115Minimum Characters to be Added at Front to Make String Palindrome568
116Remove all duplicates in a sorted linked list567
117Rearrange a given linked list in-place564
118Minimum number of Merge Operations to make an Array Palindrome564
119Most repeating character in a string564
120Rotate string to get lexicographically minimum string560
121Repeated Subsequence of Length Two or More558
122Print all anagrams together in a sequence of words555
123Reorder an Array According to the Given Indexes551
124Pancake Sorting Problem544
125Two Sum Leetcode Solution542
126Merge Overlapping Intervals II540
1273Sum Leetcode Solution539
128Clone a Linked List with next and random pointer538
129Transpose of a Matrix530
130Size of The Subarray With Maximum Sum529
131Remove duplicates from a string524
132Removing Spaces from a String using stringstream523
133Remove Extra Spaces from a String522
134Maximum Sum Increasing Subsequence521
135Smallest Palindrome after Replacement521
136Check if a given string is a rotation of a palindrome519
137Partition Problem518
138Longest Palindrome can be Formed by Removing or Rearranging Characters517
139Check whether Strings are K Distance Apart or Not508
140Generate all Binary Strings from Given Pattern506
141Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized504
142Delete Last Occurrence504
143Insert Node in the Sorted Linked List504
144Length of Longest valid Substring500
145Check if Two given Strings are Isomorphic to each other495
146Maximum difference between two elements such as larger element comes after smaller489
147Program to Toggle all Characters in a String486
148Given string is interleaving of two other strings or not486
149Count Minimum Steps to Get the given Array482
150Number of Smaller Elements on Right Side481
151Merge sort better than quick sort for linked lists480
152Find Pair with Given Difference478
153Check length of a String is Equal to the Number Appended at its Last477
154Find nth node of the Linked list from the end472
155Check if all Rows of a Matrix are Circular Rotations of Each Other472
156Longest Common Prefix using Divide and Conquer470
157Find a Fixed Point in a Given Array467
158Sort 0s 1s and 2s in an Array465
159Print all interleavings of given two strings461
160Find the Subarray of given length with Least Average458
161Reverse words in a given string457
162Compare Two Version Numbers457
163Median of Two Sorted Arrays LeetCode Solution455
164Split linked list using alternate nodes454
165Merge two sorted linked lists such that merged list is in reverse order454
166Reorder Array Using Given Indexes453
167Print Reverse of a string (Recursion)453
168Print string of odd length in ‘X’ format444
169Find K Length Subarray of Maximum Average440
170Find Element Using Binary Search in Sorted Array437
171Swap Kth Node from beginning with Kth Node from End434
172Print all Palindromic Partitions of a String432
173Find Duplicates in an Array in Most Efficient Way431
174print all palindromic partitions422
175Maximum Length of Chain Pairs419
176Shortest Superstring Problem418
177Flatten a multilevel linked list416
178Check if String Follows Order of Characters by a Pattern or not415
179Sorting a K Sorted Array412
180Sort a String According to Another String408
181Longest Span with same Sum in two Binary Arrays II402
182Reverse a Linked List in groups399
183Find a Sorted Subsequence of size 3399
184Program to add two binary digits396
185Recursively print all the sentences that can be formed from list of word lists394
186Find the two Numbers with Odd Occurrences in an Unsorted Array390
187Longest Common Prefix Using Binary Search II386
188Caesar Cipher385
189Reverse a Singly Linked List (Iterative/Non-Recursive)384
190Check if String can Become Empty by Recursively Deleting given Substring381
191Kth Non-repeating Character381
192Rearrange a linked list in Zig-Zag379
193Rotate Image by 90 degrees378
194Pancake Sorting377
195Permutations of a Given String Using STL372
196Longest Common Prefix Word by Word Matching372
197Perfect Reversible String370
198Merging Two Sorted Arrays366
199Increasing Subsequence of Length three with Maximum Product365
200Sort a linked list with 0s, 1s and 2s364
201Find the point where a monotonically increasing function becomes positive first time362
202Find First non-repeating character in a string362
203Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes362
2041`s and 2`s complement of binary number361
205Four Elements that Sum to Given355
206Delete N nodes after M354
207List items containing all characters of a given word354
208Count Number of Occurrences in a Sorted Array350
209Longest Common Prefix using Character by Character Matching349
210Split a string344
211Palindrome string (number)343
212Minimum Characters to be Removed to Make a Binary String Alternate341
213Recursive Implementation of atoi()339
214Check if a Linked list of Strings form a Palindrome335
215Print All Distinct Elements of the Array335
216Even Substring Count333
217Valid Parentheses LeetCode Solution332
218Sorting the array of strings332
219Convert a String that is Repetition of a Substring of Length K331
220Reverse a singly linked list recursively331
221Maximum occurring character in a string329
222Find the first Repeating Number in a Given Array328
223Can we reverse a linked list in less than O(n) time ?326
224Print Shortest Path to Print a String on Screen325
225Binary Tree to Doubly linked list323
226Convert string1 to string2 in one edit322
227Nth Character in Concatenated Decimal String322
228Reverse a String using Stack322
229Sort Elements by Frequency II320
230Maximum Subarray Leetcode Solution320
231wildcard character matching319
232Lower Case To Upper Case317
233Count the number of words315
234Merge Two Sorted Arrays313
235Find the Lost Element From a Duplicated Array311
236Split Four Distinct Strings311
237Find middle of the Linked List310
238Longest Common Subsequence with Permutations306
239Count the Pairs at Same Distance as in English Alphabets302
240Matrix Chain Multiplication using Dynamic Programming298
241Next Greater Element in an Array295
242Palindrome Permutation293
243Roman to Integer Leetcode Solution289
244Find Nth Node286
245Triplet from three linked lists with given sum285
246Searching a node in a Binary Search Tree285
247Find All Pairs With a Given Difference284
248String(represents an integer) to value282
249Delete a Tree281
250Word Search Leetcode Solution280
251Reverse Bits279
252Reverse a String279
253Print all Possible Ways to Break a String in Bracket Form278
254Binary Tree276
255Delete a node under given conditions274
256How to Efficiently Implement k Stacks in a Single Array?274
257Change Gender of a given String273
258Sort an array of strings272
259First non Repeating Element272
260Meeting Rooms II LeetCode Solution271
261Count Pairs With Given Sum270
262Longest Common Extension269
263Number of sub-strings which recursively add up to 9269
264Remove middle points in a linked list of line segments269
265Repeated Substring Pattern268
266Toeplitz Matrix266
267Move all negative elements to one side of array266
268Longest Palindromic Substring LeetCode Solution264
269Remove spaces from a string263
270Shuffle a given Array263
271Min Stack262
272N queen problem261
273Cuckoo sequence program257
274Number of Islands LeetCode Solution255
275Dijkstra Algorithm254
276Minimize the maximum difference between the heights253
277Max stack253
278House Robber Leetcode Solution253
279Find, second, frequent, character252
280Most Frequent Element in an Array249
281Clone a linked list with next and random pointer (Hashing)249
282Search Insert Position Leetcode Solution249
283Valid Palindrome Leetcode Solution247
284Expression Evaluation247
285KMP Algorithm246
286Sort linked which is sorted on absolute values246
287Subset Leetcode245
288Sudoku Solver245
289Reverse words in a string244
290Number Of 1 bits243
291Min Stack Leetcode Solution243
292Fibonacci numbers243
293Combination Sum Leetcode Solution242
294Plus One Leetcode Solution242
295How to Delete a Linked List241
296Evaluation of Postfix Expression241
297Word Search240
298Backspace String Compare236
299Merge Sorted Arrays Leetcode Solution234
300Set Matrix Zeroes233
301Sqrt(x) Leetcode Solution233
302Pair of Positive Negative Values in an Array232
303Reversing a Queue232
304Subarray with 0 sum232
305Rabin Karp Algorithm231
306Contains Duplicate II Leetcode Solution230
307Common elements in all rows of a given matrix229
308Product of array except self229
309Tower Of Hanoi227
310Pascal Triangle Leetcode226
311Delete middle element of a stack226
312Intersection of Two Arrays II Leetcode Solution226
313Integer to Roman Leetcode Solution226
314Combination Sum226
315String Compression224
316Reverse individual words224
317Minimum swaps required to bring all elements less than or equal to k together222
318Find Top K (or Most Frequent) Numbers in a Stream222
319Arithmetic Expression Evaluation221
320Count subarrays with equal number of 1’s and 0’s221
321Count of index pairs with equal elements in an array221
322Sliding Window Technique221
323Construct Binary Tree from Given Inorder and Preorder Traversals221
324Implementation of Deque using Doubly Linked List220
325Bellman Ford Algorithm220
326Single Number Leetcode Solution220
327Add Binary Leetcode Solution219
328Minimum Value to Get Positive Step by Step Sum Leetcode Solution219
329Second Most Repeated Word in a Sequence218
330Palindrome Linked List Leetcode Solution218
331Contains Duplicate218
332Segregate even and odd numbers218
333Sort elements by frequency217
334Pow(x, n) Leetcode Solution217
335Count Odd Numbers in an Interval Range Leetcode Solution216
336Page Replacement Algorithms in Operating Systems216
337Find sum of non-repeating elements (distinct) elements in an array216
338Design a stack that supports getMin() in O(1) time and O(1) extra space216
339Postfix to Infix Conversion216
340Kruskal Algorithm215
341Maximum Number of Balloons Leetcode Solution215
342Next Permutation215
343Third Maximum Number Leetcode Solution214
344K-th Smallest Element in a Sorted Matrix212
345Group Words With Same Set of Characters212
346Sum of minimum and maximum elements of all subarrays of size k211
347Permutations Leetcode Solution211
348Convex Hull Algorithm211
349Find the Town Judge Leetcode Solution210
350Longest Common Prefix Leetcode Solution210
351Longest Substring Without Repeating Characters LeetCode Solution210
352Smallest Subarray with k Distinct Numbers210
353Top K Frequent Words209
354Find Lucky Integer in an Array Leetcode Solution209
355Maximum Subarray208
356Find Numbers with Even Number of Digits Leetcode Solution208
357Scramble String208
358Majority Element Leetcode Solution208
359Spiral Matrix LeetCode Solution208
360Swap Nodes in Pairs Leetcode Solutions207
361Count subarrays having total distinct elements same as original array207
362Minimum operation to make all elements equal in array206
363First element occurring k times in an array206
364Sorting array using Stacks206
365Evaluate Division206
366Prefix to Infix Conversion205
367Number of Good Pairs Leetcode Solution205
368Merge Two Sorted Lists Leetcode Solutions205
369Minimum Path Sum205
370Missing Number Leetcode Solution205
371Best Time to Buy and Sell Stock  II Leetcode Solution204
372Special Number204
373Count Primes Leetcode Solutions204
374Check if two arrays are equal or not204
375Given two unsorted arrays find all pairs whose sum is x204
376Reverse a Number Using Stack203
377Minimum Absolute Difference Leetcode Solution203
378Search in Rotated Sorted Array Leetcode Solution203
379Power of Two Leetcode Solution202
380Pascal’s Triangle II Leetcode Solution202
381Top K Frequent Elements202
382Huffman Coding202
383Sort Array by Increasing Frequency Leetcode Solution202
384Minimum Steps to reach target by a Knight201
385Unique Paths Leetcode Solution201
386Find All Numbers Disappeared in an Array Leetcode Solution201
387House Robber II Leetcode Solution201
388Maximal Square201
389Find duplicates in a given array when elements are not limited to a range201
390Fizz Buzz Leetcode200
391Reversing the First K elements of a Queue200
392Single Number200
393Maximum possible difference of two subsets of an array199
394Matrix Diagonal Sum Leetcode Solution199
395How Many Numbers Are Smaller Than the Current Number Leetcode Solution199
396Running Sum of 1d Array Leetcode Solution199
397Sorting using trivial hash function199
398Leetcode Permutations198
399Group Anagrams198
400Find Minimum In Rotated Sorted Array198
401Sort Integers by The Number of 1 Bit Leetcode Solution198
402Maximum Distance Between two Occurrences of Same Element in Array197
403How to Implement Stack Using Priority Queue or Heap?197
404Happy Number Leetcode Solution197
405Coin Change 2 Leetcode Solution197
406Max Consecutive Ones Leetcode Solution196
407Unique Paths196
408Range Sum Query 2D – Immutable Leetcode Solution196
409Difference between highest and least frequencies in an array195
410Zigzag Conversion195
411Find Winner on a Tic Tac Toe Game Leetcode Solution195
412Remove Duplicates from Sorted Array Leetcode Solution195
413Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution195
414Find the Closest Palindrome number195
415Convert String To Int195
416Decode String195
417Expression Contains Redundant Bracket or Not195
418Find Number of Employees Under every Employee195
419Subarray Sum Equals k194
420Best Time to Buy and Sell Stock III Leetcode Solution194
421Subarray Sum Equals K LeetCode Solution194
422Smallest Element Repeated Exactly K Times194
423Fibonacci Number LeetCode Solution194
424Check if Array Contains Contiguous Integers With Duplicates Allowed194
425Monotonic Array LeetCode Solution194
426Length of the largest subarray with contiguous elements194
427Subset sum problem193
428Reverse Integer193
429Capacity To Ship Packages Within D Days Leetcode Solution193
430Reverse Vowels of a String Leetcode Solution193
431Find The Duplicate Number193
432Delete a Node from linked list without head pointer192
433Check If N and Its Double Exist Leetcode Solution192
434Implement Stack and Queue using Deque192
435Palindrome Substring Queries192
436Reverse a Stack Using Recursion192
437Subtract the Product and Sum of Digits of an Integer Leetcode Solution192
438Find Median from data Stream192
439Find top three repeated in array191
440Maximum Depth of Binary Tree Leetcode Solution191
441Generate a String With Characters That Have Odd Counts Leetcode Solution191
442Letter Case Permutation191
443Shuffle the Array Leetcode Solution191
444LRU Cache Implementation191
445Nth Catalan Number191
446Cumulative Frequency of Count of Each Element in an Unsorted Array190
447Priority Queue Using Singly Linked List190
448Find the Duplicate Element190
449Trapping Rain Water Leetcode Solution190
450Reverse Words in a String III LeetCode Solution190
451Sort a stack using recursion190
452Print All Distinct Elements of a Given Integer Array190
453Target Sum189
454Find Common Characters Leetcode Solution189
455Reverse a String189
456Kth largest element in an Array Leetcode Solutions189
457Sorting a Queue without Extra Space189
458Subarrays with distinct elements189
459Find the first repeating element in an array of integers188
460Count Substrings with equal number of 0s, 1s and 2s188
461Integer to English words188
462Bipartite Graph188
463Longest Common Subsequence188
464Sum of Subarray Ranges Leetcode Solution188
465Iterative Tower of Hanoi188
466Prim’s Algorithm187
467Find First and Last Position of Element in Sorted Array Leetcode Solution187
468Find the Difference Leetcode Solution187
469Word Ladder LeetCode Solution187
470Find all pairs (a, b) in an array such that a % b = k187
471The K Weakest Rows in a Matrix Leetcode Solution187
472Kids With the Greatest Number of Candies Leetcode Solution187
473Print all subarrays with 0 sum187
474Excel Sheet Column Number Leetcode Solution187
475Balanced Binary Tree Leetcode Solution187
476Minimum Moves to Equal Array Elements Leetcode Solution187
477Concatenation of Array LeetCode Solution186
478Floyd Warshall Algorithm186
479Count pairs from two linked lists whose sum is equal to a given value186
480Merge Two Sorted Linked Lists186
481Text Justification LeetCode Solution185
482Find elements which are present in first array and not in second185
483Merge Overlapping Intervals185
484Kth Largest Element in a Stream Leetcode Solution185
485Number of Steps to Reduce a Number to Zero Leetcode Solution185
486Fizz Buzz185
487Next Greater Element I Leetcode Solution185
488Zigzag Conversion LeetCode Solution184
489Edit Distance184
490Multiply Strings Leetcode Solution184
491Remove Minimum Number of Elements Such That no Common Element Exist in both Array183
492Degree of an array183
493Count and Say Leetcode Solution183
494Prefix to Postfix Conversion183
495Design Parking System Leetcode Solution183
496Slowest Key Leetcode Solution183
497Count and Say183
498Flood Fill LeetCode183
499Reverse a linked list183
500Move Zeroes LeetCode Solution183
501Max Area of Island182
502Implement a stack using single queue182
503Shuffle String Leetcode Solution182
504The Stock Span Problem182
505Intersection of Two Arrays182
506MiniMax Algorithm182
507Mobile Numeric Keypad Problem182
508Jump Game Leetcode Solution181
509Top View of Binary Tree181
510Valid Parenthesis String181
511Longest Common Prefix using Trie181
512Next Greater Frequency Element181
513Length of Last Word Leetcode Solution181
514Priority Queue in C++181
515Substring With Concatenation Of All Words181
516Peak Index in a Mountain Array180
517Convert array into Zig-Zag fashion180
518Find subarray with given sum (Handles Negative Numbers)180
519Find N Unique Integers Sum up to Zero Leetcode Solution180
520Find distinct elements common to all rows of a matrix180
521Last Stone Weight180
522Longest subarray not having more than K distinct elements179
523Postfix to Prefix Conversion179
524Pair with given product179
525Recursion179
526Container with Most Water178
527Find four elements that sum to a given value (Hashmap)178
528Contiguous Array Leetcode178
529Find any one of the multiple repeating elements in read only array178
530Shortest Palindrome178
531Iterative Inorder Traversal of a Binary Tree178
532Longest Common Prefix using Sorting178
533N-th Tribonacci Number Leetcode Solution178
534Smallest Subarray With all Occurrences of a Most Frequent Element178
535Delete Node in a Linked List Leetcode Solution178
536Find Index of Closing Bracket for a Given Opening Bracket in an Expression178
537Relative Sort Array Leetcode Solution178
538Isomorphic Strings Leetcode Solution177
539Jewels and Stones Leetcode Solution177
540Is Subsequence Leetcode Solution177
541Count number of triplets with product equal to given number177
542Best Time to Buy and Sell Stock177
543Minimum Operations to convert X to Y177
544Implement Stack using Queues177
545Find missing elements of a range177
546Convert a normal BST to Balanced BST177
547Excel Sheet Column Title Leetcode Solution177
548Check if a given array contains duplicate elements within k distance from each other177
549Koko Eating Bananas Leetcode Solution177
550Implementation of Deque using circular array176
551Largest Perimeter Triangle Leetcode Solution176
552Remove Linked List Elements Leetcode Solution176
553First negative integer in every window of size k176
554Sum of Left Leaves Leetcode Solutions176
555Check for Balanced Parentheses in an Expression175
556Build Array From Permutation Leetcode Solution175
557Linked List Cycle II LeetCode Solution175
558Find Words That Can Be Formed by Characters Leetcode Solution175
55901 Matrix LeetCode Solution175
560K-th Distinct Element in an Array175
561Largest Sum Contiguous Subarray174
562Group Multiple Occurrence of Array Elements Ordered by first Occurrence174
563Convert Sorted Array to Binary Search Tree Leetcode Solution174
564Maximum sum rectangle in a 2D matrix174
565Island Perimeter Leetcode Solution174
566Assign Cookies Leetcode Solution174
567Change the Array into Permutation of Numbers From 1 to N174
568Minimum Bracket Reversals174
569Distribute Candies to People Leetcode Solution174
570Arrange given numbers to form the biggest number174
571Valid Sudoku174
572Shuffle an Array174
573Valid Anagrams174
574Integer to Roman173
575Count the number of nodes at given level in a tree using BFS173
576Hamming Distance173
577Summary Ranges Leetcode Solution173
578Rotate List Leetcode Solution173
579Combinations Leetcode Solution173
580Find the smallest positive integer value that cannot be represented as sum of any subset of a given array173
581Unique Binary Search Trees172
582Gold Mine Problem172
583Decode Ways172
584Insert Interval Leetcode Solution172
585Maximum path sum in a triangle172
586Count all subsequences having product less than K172
587Trapping Rain Water LeetCode Solution172
588The Knapsack Problem172
5893Sum Closest LeetCode Solution172
590Maximum Distance in Array171
591Rotate Image LeetCode Solution171
592Maximum Number of Chocolates to be Distributed Equally Among k Students171
593Minimum Delete Operations to make all Elements of Array Same171
594Distance Between Bus Stops Leetcode Solution171
595Shortest Path in a Grid with Obstacles Elimination LeetCode Solution171
596Minimum number of distinct elements after removing m items171
597Same Tree LeetCode Solution170
598Minimum Knight Moves LeetCode Solution170
599Permutation in String Leetcode Solution170
600LRU Cache LeetCode Solution170
601Rearrange a binary string as alternate x and y occurrences170
602Sieve of Eratosthenes170
603Minimum number of subsets with distinct elements169
604K Empty Slots LeetCode169
605Remove All Occurrences of a Substring LeetCode Solution169
606Stone Game LeetCode169
607Find the Duplicate Number LeetCode Solution168
608XOR Operation in an Array Leetcode Solution168
609Printing brackets in Matrix Chain Multiplication Problem168
610How to check if two given sets are disjoint?168
611Defanging an IP Address Leetcode Solution168
612Word Pattern167
613Minimum Depth of Binary Tree Leetcode Solution167
614Find if an Expression has Duplicate Parenthesis or Not167
615Segregate 0s and 1s in an Array167
616Maximum Consecutive Numbers Present in an Array167
617Minimum insertions to form a palindrome with permutations allowed167
618Replace Elements with Greatest Element on Right Side Leetcode Solution167
619Distance of nearest cell having 1 in a binary matrix167
620Applications of Breadth First Search and Depth First Search167
621Painting Fence Algorithm167
622House Robber167
623Find Sum of all unique sub-array sum for a given array167
624Sort Array By Parity LeetCode Solution167
625Word Wrap Problem167
626Best Time to Buy and Sell Stock LeetCode Solution167
627Tracking current Maximum Element in a Stack167
628Sort Characters By Frequency LeetCode Solution167
629Coin Change Problem167
630Frog Jump Leetcode Solution166
631Smallest Good Base166
632Find minimum difference between any two elements166
633Maximum difference between first and last indexes of an element in array166
634License Key Formatting Leetcode Solution166
635Check If It Is a Straight Line Leetcode Solution166
636Sum of All Odd Length Subarrays Leetcode Solution165
637Isomorphic Strings165
638Longest Substring with At Least K Repeating Characters LeetCode Solution165
639Best Time to Buy and Sell Stock with Cooldown Leetcode Solution165
640Longest Substring with At Most K Distinct Characters LeetCode Solution165
641Count Good Nodes in Binary Tree Leetcode Solution165
642Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions165
643Wiggle Sort164
644Minimum Cost to Hire K Workers164
645Find Maximum Level sum in Binary Tree164
646Maximum Number of Occurrences of a Substring Leetcode Solution164
647Letter Combinations of a Phone Number164
648Queries for counts of array elements with values in given range164
649Kth Missing Positive Number Leetcode Solution164
650Optimal Account Balancing LeetCode Solution164
651Iterative Method to find Height of Binary Tree164
652Employee Free Time LeetCode Solution164
653Binary Tree Zigzag Level Order Traversal LeetCode Solution164
654Merge Two Balanced Binary Search Trees164
655Find pairs with given sum such that elements of pair are in different rows163
656GCD Of Two Numbers163
657Reorganize String163
658Valid Perfect Square Leetcode Solution163
659Partition Labels LeetCode Solution163
660Non-overlapping sum of two sets163
661Strobogrammatic Number LeetCode Solution163
662Power of Four Leetcode Solution163
663Valid Palindrome II Leetcode Solution163
664Number of Provinces Leetcode Solution163
665Maximum Number of Coins You Can Get Leetcode Solution162
666Find the Distance Value Between Two Arrays Leetcode Solution162
667Reverse a stack without using extra space in O(n)162
668Moving Average from Data Stream Leetcode Solution162
669Delete consecutive same words in a sequence162
670Print the Fibonacci numbers in reverse order162
671Edit Distance LeetCode Solution162
672Valid Palindrome162
673Ugly Number Leetcode Solution161
674Path With Maximum Minimum Value LeetCode Solution161
675Sort Array by Increasing Frequency Leetcode Solution161
676Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest161
677String to Integer (atoi) LeetCode Solution161
678Dynamic Programming Basics161
679Permutation Sequence LeetCode Solution161
680To Lower Case Leetcode Solution161
681Longest Increasing Subsequence161
682Partition Array Into Three Parts With Equal Sum Leetcode Solution160
683Convert an array to reduced form160
684Restore IP Addresses Leetcode Solution160
685Reducing Dishes LeetCode Solution160
686Recover Binary Search Tree160
687Factorial Trailing Zeroes Leetcode Solution160
688Longest Increasing Path in a Matrix LeetCode Solution160
689Find Leaves of Binary Tree LeetCode Solution160
690Number of Dice Rolls With Target Sum LeetCode Solution160
691Check if a queue can be sorted into another queue using a stack160
692Flipping an Image LeetCode Solution160
693Check If Two String Arrays are Equivalent Leetcode Solution160
694BFS vs DFS for Binary Tree160
695Find Largest d in Array such that a + b + c = d160
696Reversing a Queue using Recursion160
697Reverse Only Letters LeetCode Solution160
698K Empty Slots160
699Maximum Product of Two Elements in an Array Leetcode Solution160
700Subset Sum Leetcode160
701Unique Paths II Leetcode Solution159
702Remove Invalid Parentheses Leetcode Solution159
703Reservoir Sampling159
704Form minimum number from given sequence159
705Find whether an array is subset of another array159
706Majority Element II Leetcode Solution159
707Increasing Decreasing String Leetcode Solution159
708Inorder Successor of a node in Binary Tree159
709Construct BST from given Preorder Traversal159
710Binary Tree zigzag level order Traversal159
711Delete Nth node from the end of the given linked list159
712Bulb Switcher LeetCode Solution158
713Find the Smallest Divisor given a Threshold Leetcode Solution158
714Minimum Cost For Tickets Leetcode Solution158
715How to Create Mergable Stack?158
716Convert a Number to Hexadecimal Leetcode Solution158
717Robot Room Cleaner Leetcode Solution158
718Populating Next Right Pointers in Each Node158
719Lucky Numbers in a Matrix Leetcode Solution158
720Find Pair with Greatest Product in Array157
721Perform String Shifts Leetcode157
722Morris Traversal157
723Keyboard Row Leetcode Solution157
724Merge Two Binary Trees LeetCode Solution157
725Sum of f(a[i], a[j]) over all pairs in an array of n integers157
726Find the node with minimum value in a Binary Search Tree156
727First Unique Character in a String LeetCode Solution156
728Bubble sort using two Stacks156
729Add and Search Word – Data structure design LeetCode156
730Rank Transform of an Array Leetcode Solution156
731Student Attendance Record I Leetcode Solution155
732Finding K closest element155
733Maximum 69 Number Leetcode Solution155
734Maximum Product of Three Numbers LeetCode Solution155
735Best Meeting Point LeetCode Solution155
736Sorted Linked List to Balanced BST155
737Decompress Run-Length Encoded List Leetcode Solution155
738Hamming Distance Leetcode Solution155
739Largest subarray with equal number of 0s and 1s154
740Split a String in Balanced Strings Leetcode Solution154
741Search a 2D Matrix II Leetcode Solution154
742Word Pattern LeetCode Solution154
743Invert Binary Tree LeetCode Solution154
744Find unique character in a string154
745Merge K Sorted Linked Lists154
746String Compression LeetCode Solution154
747Symmetric Tree Leetcode Solution154
748Number of Islands II LeetCode Solution154
749Tiling Problem154
750Find Median from Data Stream LeetCode Solution154
751Evaluate Reverse Polish Notation LeetCode Solution154
752Minimum Distance Between BST Nodes Leetcode Solution154
753Minimum time required to rot all oranges154
754Find All Duplicates in an Array LeetCode Solution154
755Diagonal Traversal of Binary Tree154
756Non-decreasing Array LeetCode Solution154
757Queue based approach for first non-repeating character in a stream154
758Maximum Depth of N-ary Tree Leetcode Solution154
759Binary Tree Maximum Path Sum LeetCode Solution154
760Largest rectangular sub-matrix whose sum is 0154
761Generate all possible sorted arrays from alternate elements of two given sorted arrays154
762Minimum Height Trees154
763Snakes and Ladders LeetCode Solution154
764Maximum Difference Between Increasing Elements LeetCode Solution154
765k-th missing element in increasing sequence which is not present in a given sequence153
766Find if Path Exists in Graph Leetcode Solution153
767Deletion in a Binary Tree153
768Find the largest multiple of 3153
769Numbers with prime frequencies greater than or equal to k153
770Kth ancestor of a node in binary tree153
771Elements to be added so that all elements of a range are present in array153
772Special Array With X Elements Greater Than or Equal X Leetcode Solution153
773Maximum Length of a Concatenated String with Unique Characters Leetcode Solution153
774Jump Game153
775Binomial Coefficient153
776Stack Permutations (Check if an array is stack permutation of other)153
777Check If Array Pairs Are Divisible by k LeetCode Solution153
778Minimize Maximum Pair Sum in Array LeetCode Solution153
779Transpose Graph153
780Minimum number of jumps to reach end152
781Find Maximum Depth of Nested Parenthesis in a String152
782Longest Span with same Sum in two Binary arrays152
783Remove Nth Node From End of List Leetcode Solution152
784Minimum swaps to make sequences increasing152
785Search in a Binary Search Tree Leetcode Solution152
786Program for Bridge and Torch problem152
787Minimum Time Visiting All Points Leetcode Solution152
788Largest Rectangle in Histogram LeetCode Solution152
789Count quadruples from four sorted arrays whose sum is equal to a given value x152
790N-Queens LeetCode Solution152
791Remove Duplicates from Sorted List II152
792Race Car LeetCode Solution151
793Linked List Cycle151
794Final Prices With a Special Discount in a Shop Leetcode Solution151
795Remove brackets from an algebraic string containing + and – operators151
796Crawler Log Folder Leetcode Solution151
797String comparison containing wildcards151
798Minimum Jumps to Reach Home LeetCode Solution151
799Partition to K Equal Sum Subsets Leetcode Solution151
800Number of NGEs to the Right151
801Base 7 Leetcode Solution151
802Remove Duplicates from Sorted List LeetCode Solution151
803Interval Tree151
804Brick Wall LeetCode Solution150
805Number Complement Leetcode Solution150
806Check if Two Expressions With Brackets are Same150
807Iterative Preorder Traversal150
808Nested List Weight Sum II LeetCode Solution150
809Maximum Profit in Job Scheduling Leetcode Solution150
810Check for Palindrome after every character replacement Query150
811Nearest Exit from Entrance in Maze LeetCode Solution150
812Total Numbers With no Repeated Digits in a Range150
813Relative Ranks Leetcode Solution150
814A Space Optimized DP solution for 0-1 Knapsack Problem150
815Maximum size subarray sum equals k149
816Alien Dictionary LeetCode Solution149
817Reorder Data in Log Files LeetCode Solution149
818Get Maximum in Generated Array Leetcode Solution149
819Growable array based stack149
820Can Place Flowers LeetCode Solution149
821Print a Binary Tree in Vertical Order149
822Find the subarray with least average149
823Valid Parentheses Leetcode Solution149
824Find all triplets with zero sum149
825Merge Sorted Array LeetCode Solution149
826Convert BST to Min Heap149
827One Edit Distance LeetCode Solution149
828Regular Expression Matching148
829Sort Colors148
830Find the Only Repetitive Element Between 1 to N-1148
831Sort an array according to the order defined by another array148
832Count Distinct Elements in Every Window of Size K148
833Partition List Leetcode Solution148
834Count items common to both the lists but with different prices148
835Design a Stack With Increment Operation Leetcode Solution148
836Sort Array By Parity II Leetcode Solution148
837Path with maximum average value148
838Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution148
839Clone Graph LeetCode Solution148
840Valid Number148
841Check if a given array can represent Preorder Traversal of Binary Search Tree148
842Check whether a given Binary Tree is Complete or not148
843Find All Possible Recipes from Given Supplies LeetCode Solution148
844Level order Traversal in Spiral Form147
845Top K Frequent Words LeetCode Solution147
846Minimum Number of Taps to Open to Water a Garden LeetCode Solution147
847Form Minimum Number From Given Sequence147
848Longest Subarray Having Count of 1s One More than Count of 0s147
849Last Stone Weight II LeetCode Solution147
850Subset with sum divisible by m147
851Subsequence of Size K With the Largest Even Sum LeetCode Solution147
852Friends Pairing Problem147
853Insert into a Binary Search Tree Leetcode Solution147
854Priority Queue using doubly linked list147
855Count Negative Numbers in a Sorted Matrix LeetCode Solution147
856Subarray Product Less Than K LeetCode Solution147
857Maximum Nesting Depth of the Parentheses Leetcode Solution147
858Permutation Coefficient146
859GCDs of given index ranges in an array146
860Guess Number Higher or Lower LeetCode Solution146
861Course Schedule II – LeetCode146
862Sum of nearest smaller and greater number146
863K’th Largest Element in BST when modification to BST is not allowed146
864Repeated Substring Pattern LeetCode Solution146
865Minimum Sum Path in a Triangle146
866Circular Queue146
867Tree Traversal (Preorder, Inorder & Postorder)146
868Matrix Chain Multiplication146
869Brightest Position on Street LeetCode Solution146
870Given an Array of Pairs Find all Symmetric Pairs in it146
871Binary Search Tree Search and Insertion146
872Distinct adjacent elements in an array146
873Daily Temperatures Leetcode Solution145
874Union and Intersection of two Linked Lists145
875Three way partitioning of an array around a given range145
876An Interesting Method to generate Binary Numbers from 1 to n145
877Minimum Swaps to Make Strings Equal Leetcode Solution145
878Spiral Matrix II Leetcode Solution145
879Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution145
880Sorted Array to Balanced BST145
881Sequences of given length where every element is more than or equal to twice of previous145
882Number of Days Between Two Dates LeetCode Solution145
883Count ways to reach the nth stair using step 1, 2 or 3144
884Check if an Array is Stack Sortable144
885Find Maximum Sum Possible Equal Sum of Three Stacks144
886Check if stack elements are pairwise consecutive144
887Lemonade Change Leetcode Solution144
888Delete And Earn144
889Guess Number Higher or Lower II144
890Design Browser History LeetCode Solution144
891Robot Bounded In Circle LeetCode Solution144
892Diagonal Traverse LeetCode Solution144
893Minimum sum of multiplications of n numbers144
894Destination City Leetcode Solution143
895Rearrange Spaces Between Words Leetcode Solution143
896Water Bottles Leetcode Solution143
897Range sum queries without updates143
8984Sum143
899Diagonal Traversal LeetCode Solution143
900Missing Element in Sorted Array LeetCode Solution143
901Find distance between two nodes of a Binary Tree143
902Spiral Matrix III LeetCode Solution143
903Check if the given array can represent Level Order Traversal of Binary Search Tree143
904LCS (Longest Common Subsequence) of three strings143
905Shortest Word Distance Leetcode Solution142
906Identify and Mark Unmatched Parenthesis in an Expression142
907A program to check if a binary tree is BST or not142
908Balanced Expression with Replacement142
909Construct Complete Binary Tree from its Linked List Representation142
910Queries for GCD of all numbers of an array except elements in a given range142
911Set Matrix Zeroes Leetcode Solution142
912Least Number of Unique Integers after K Removals Leetcode Solution142
913Time Based Key-Value Store LeetCode Solution142
914Palindrome Partitioning Leetcode Solution142
915Special Positions in a Binary Matrix Leetcode Solution142
916Maximum Score After Splitting a String Leetcode Solution142
917BFS for Disconnected Graph141
918Remove Duplicates from Sorted List II LeetCode Solution141
919Convert Sorted List to Binary Search Tree141
920Construct BST from its given Level Order Traversal141
921Trim a Binary Search Tree141
922Iterative Postorder Traversal Using Two Stacks141
923All Unique Triplets that Sum up to a Given Value141
924Number of Distinct Islands Leetcode Solution141
925Strongly Connected Component141
926Rearrange an Array Such that arr[i] is equal to i141
927Construct the Rectangle Leetcode Solution141
928Insert Delete GetRandom141
929Alien Dictionary141
930Infix to Postfix140
931Intersection of Two Linked Lists LeetCode Solution140
932Merging Intervals140
933Find all permuted rows of a given row in a matrix140
9343 Sum140
935Collect maximum points in a grid using two traversals140
936Find Common Characters Leetcode Solution140
937Reverse Nodes in K-Group140
938Count Subarrays with Same Even and Odd Elements140
939Queue using Stacks140
940Longest Palindromic Subsequence140
941Difference Array | Range update query in O(1)140
942Maximum Frequency Stack Leetcode Solution140
943Lexicographical Numbers Leetcode Solution140
944Range LCM Queries140
945Count Submatrices With All Ones LeetCode Solution140
946Split Array Into Consecutive Subsequences140
947Count pair with Given Sum139
948Find the Difference Leetcode Solution139
949Vertical sum in a given binary tree139
950Check if any two intervals overlap among a given set of intervals139
951Averages of Levels in Binary Tree139
952Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i139
953Merge Two Sorted Lists Leetcode139
954Number of Equivalent Domino Pairs Leetcode Solution139
955Word Break139
956Can Make Arithmetic Progression From Sequence Leetcode Solution139
957Binary Tree Longest Consecutive Sequence LeetCode Solution139
958Stone Game II Leetcode138
959Minimum Height Trees LeetCode Solution138
960Analyze User Website Visit Pattern LeetCode Solution138
961Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space138
962Print Fibonacci sequence using 2 variables138
963Maximize Sum of Array after K Negations Leetcode Solution138
964Largest area rectangular sub-matrix with equal number of 1’s and 0’s137
965Three Consecutive Odds Leetcode Solution137
966Binary array after M range toggle operations137
967Palindrome Partitioning137
968Sliding Window Maximum137
969Longest Nice Substring LeetCode Solution137
970Product of Array Except Self LeetCode Solution137
971Find postorder traversal of BST from preorder traversal136
972Dividing Array into Pairs With Sum Divisible by K136
973Maximum Product of Indexes of Next Greater on Left and Right136
974Count Primes in Ranges136
975Boolean Parenthesization Problem136
976Level order traversal using two Queues136
977Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution136
978Symmetric Tree136
979Largest divisible pairs subset136
980Breadth First Search (BFS) for a Graph136
981K Closest Points to Origin Leetcode Solution136
982Unique Paths II136
983Create Maximum Number136
984Minesweeper LeetCode Solution136
985Kth Smallest Element in a BST Leetcode Solution136
986Newman-Conway Sequence136
987Height of a generic tree from parent array136
988Asteroid Collision LeetCode Solution136
989Maximum Subarray Sum Excluding Certain Elements136
990Number Of Longest Increasing Subsequence136
991First missing positive135
992Find Duplicate Subtrees135
993My Calendar I LeetCode Solution135
994Level Order Traversal of Binary Tree135
995Binary Search Tree Delete Operation135
996Largest Substring Between Two Equal Characters Leetcode Solution135
997Find Maximum of Minimum for Every Window Size in a Given Array135
998Median of Two Sorted Arrays135
999Depth First Search (DFS) for a Graph135
1000Length of Longest Fibonacci Subsequence135
1001Friends Of Appropriate Ages LeetCode Solution135
1002Double the first element and move zero to end135
1003Maximum subsequence sum such that no three are consecutive135
1004Graph Valid Tree LeetCode Solution135
1005Segment Tree135
1006Next Greater Element III LeetCode Solution135
1007Maximum weight transformation of a given string135
1008The Painter’s Partition Problem135
1009Morris Inorder Traversal135
1010Pattern Occurrences using Stack135
1011The Maze III LeetCode Solution134
1012Sign of the Product of an Array LeetCode Solution134
1013Serialize and Deserialize Binary Tree134
1014Decrypt String from Alphabet to Integer Mapping Leetcode Solution134
1015Insertion in a Binary Tree134
1016Partition Equal Subset Sum134
1017Build an Array With Stack Operations Leetcode Solution134
1018Find the First Circular Tour that visits all the Petrol Pumps134
1019String Matching in an Array Leetcode Solution134
1020Maximum Product Subarray134
1021Shortest Completing Word Leetcode Solution134
1022Valid Boomerang Leetcode Solution134
1023Maximum Length of Repeated Subarray134
1024Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’134
1025Kill Process LeetCode Solution133
1026Construction of Longest Increasing Subsequence (N log N)133
1027Maximum Number of Ways to Partition an Array LeetCode Solution133
1028Design Hit Counter LeetCode Solution133
1029Count subarrays where second highest lie before highest133
1030Rearrange array such that even positioned are greater than odd133
1031Boundary Traversal of binary tree133
1032Make The String Great Leetcode Solution133
1033Largest Number Leetcode Solution133
1034Climbing stairs133
1035K maximum sums of overlapping contiguous sub-arrays133
1036Compute nCr % p133
1037Balanced Binary Tree132
1038Advantages of BST over Hash Table132
1039Super Ugly Number132
1040Scramble String LeetCode Solution132
1041Construct Binary Tree from given Parent Array representation132
1042Ugly Number II LeetCode Solution132
1043Invalid Transactions LeetCode Solution132
1044Maximum Sum of 3 Non-Overlapping Subarrays132
1045Add two numbers132
1046Validate Binary Search Tree132
1047Longest subsequence such that difference between adjacents is one132
1048Find number of pairs in an array such that their XOR is 0132
1049Ugly Numbers131
1050Custom Sort String Leetcode Solution131
1051Maximum difference between frequency of two elements such that element having greater frequency is also greater131
1052Move all negative elements to end in order with extra space allowed131
1053Generate Parentheses Leetcode Solution131
1054Binary Tree Right Side View LeetCode Solution131
1055Recover Binary Search Tree Leetcode Solution131
1056Defanging an IP Address LeetCode Solution131
1057Binary Search Tree131
1058Implement Trie (Prefix Tree) Leetcode Solution130
1059Employee Importance LeetCode Solution130
1060Find a Peak Element II LeetCode Solution130
1061Iterative Depth First Traversal of Graph130
1062Path Sum II LeetCode Solution130
1063Bitwise AND of Numbers Range LeetCode Solution130
1064Minimum Index Sum of Two Lists130
1065Find whether a subarray is in form of a mountain or not129
1066Largest BST Subtree LeetCode Solution129
1067Number of palindromic paths in a matrix129
1068Rearrange array such that even index elements are smaller and odd index elements are greater129
1069Maximum length subsequence with difference between adjacent elements as either 0 or 1129
1070Binary Tree Data Structure129
1071Serialize and Deserialize Binary Tree LeetCode Solution129
1072Count minimum steps to get the given desired array129
1073Remove Duplicates from Sorted Array II Leetcode Solution129
1074Find Smallest Range Containing Elements from k Lists129
1075Minimum Size Subarray Sum129
1076Available Captures for Rook Leetcode Solution129
1077Count pairs from two sorted arrays whose sum is equal to a given value x129
1078Kth Smallest Element in a Sorted Matrix LeetCode Solution129
1079Regular Expression Matching Regular Expression Matching LeetCode Solution129
1080Find Peak Element129
1081Increasing Triplet Subsequence LeetCode Solution128
1082Populating Next Right Pointers in Each Node Leetcode Solution128
1083Maximize Distance to Closest Person LeetCode Solution128
1084Clone a Binary Tree with Random Pointers128
1085Number of Closed Islands Leetcode Solution128
1086Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution128
1087Longest Bitonic Subsequence128
1088Combination Sum IV LeetCode Solution128
1089Remove Palindromic Subsequences Leetcode Solution128
1090Search in Sorted Rotated Array128
1091Remove duplicates from sorted array128
1092Lowest Common Ancestor128
1093Number of Students Doing Homework at a Given Time Leetcode Solution128
1094Number of siblings of a given Node in n-ary Tree127
1095Smallest Common Region Leetcode Solution127
1096Subarrays with K Different Integers Leetcode Solution127
1097Root to Leaf path with target sum Leetcode Solutions127
1098Print all triplets in sorted array that form AP127
1099Find the minimum distance between two numbers127
1100Constant time range add operation on an array127
1101Distinct Subsequences127
1102Types of Binary Tree127
1103Next Permutation Leetcode Solution126
1104Print Next Greater Number of Q queries126
1105Day of the Year Leetcode Solution126
1106Find maximum difference between nearest left and right smaller elements126
1107Find Three Element From Different Three Arrays Such That a + b + c = sum126
1108Kth Smallest Product of Two Sorted Arrays LeetCode Solution126
1109Divisible Pairs Counting126
1110Path Sum126
1111Sum of Even Numbers After Queries125
1112Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution125
1113Reformat The String Leetcode Solution125
1114Cells with Odd Values in a Matrix LeetCode Solution125
1115Write Code to Determine if Two Trees are Identical125
1116Minimum Score Triangulation of Polygon Leetcode Solution125
1117Third Maximum Number Leetcode Solution125
1118Bottom View of a Binary Tree124
1119Count Largest Group Leetcode Solution124
1120Consecutive Characters LeetCode Solution124
1121Level of Each node in a Tree from source node124
1122Minimum Absolute Difference in BST Leetcode Solution124
1123Moser-de Bruijn Sequence124
1124Print Right View of a Binary Tree124
1125Maximum Product Subarray124
1126Mean of Array After Removing Some Elements Leetcode Solution124
1127Topological Sorting124
1128Prime Palindrome LeetCode Solution123
1129Longest Subarray of 1’s After Deleting One Element LeetCode Solution123
1130Search Insert Position123
1131Products of ranges in an array123
1132Convert BST into a Min-Heap without using array123
1133Subset Sum Problem in O(sum) space123
1134Diameter of N-Ary Tree LeetCode Solution123
1135Cutting a Rod123
1136Queries for Number of Distinct Elements in a Subarray122
1137Maximum Binary Tree122
1138Check Array Formation Through Concatenation Leetcode Solution122
1139Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution122
1140Search an Element in Sorted Rotated Array122
1141Swap Nodes In Pairs122
1142Closest Binary Search Tree Value Leetcode Solution122
1143Thousand Separator Leetcode Solution122
1144Palindrome Permutation LeetCode Solution122
1145Golomb sequence122
1146Valid Tic-Tac-Toe State LeetCode Solution122
1147Construct K Palindrome Strings LeetCode Solution121
1148Bus Routes Leetcode Solution121
1149Minimum Sideway Jumps LeetCode Solution121
1150Find a sorted subsequence of size 3 in linear time121
1151Merge two BSTs with limited extra space121
1152Iterative method to find ancestors of a given binary tree121
1153Print modified array after executing the commands of addition and subtraction121
1154Kth Smallest Number in Multiplication Table Leetcode Solution121
1155Minimum sum of squares of character counts in a given string after removing k characters121
1156Binary Tree to Binary Search Tree Conversion120
1157Find maximum length Snake sequence120
1158Possible Bipartition LeetCode Solution120
1159Transform a BST to Greater sum Tree120
1160Factorial Trailing Zeroes LeetCode Solution120
1161Longest Increasing Consecutive Subsequence120
1162Longest Repeated Subsequence119
1163Swapping Nodes in a Linked List Leetcode Solution119
1164Palindromic Substrings Leetcode Solution119
1165Find the smallest binary digit multiple of given number119
1166Red-Black Tree Introduction119
1167Find Largest Value in Each Tree Row LeetCode Solution119
1168Maximize sum of consecutive differences in a circular array119
1169Search Suggestions System LeetCode Solution119
1170Maximum Product of Splitted Binary Tree LeetCode Solution119
1171Decrease Elements To Make Array Zigzag LeetCode Solution118
1172Delete Nodes and Return Forest Leetcode Solution118
1173K’th Largest element in BST using constant extra space118
1174Number of Orders in the Backlog Leetcode Solution118
1175Decision Tree118
1176Minimum Cost to Move Chips to The Same Position LeetCode Solution118
1177Count even length binary sequences with same sum of first and second half bits118
1178Minimum Moves to Equal Array Elements LeetCode Solution118
1179Compare Strings by Frequency of the Smallest Character Leetcode Solution118
1180Rotate Array118
1181Maximum sum bitonic subarray118
1182Priority Queue118
1183Graph and its representation118
1184Reverse a Path in BST using Queue117
1185Lowest Common Ancestor in Binary Search Tree117
1186Contiguous Array LeetCode Solution117
1187Matchsticks to Square Leetcode Solution117
1188How to print maximum number of A’s using given four keys117
1189Count Pairs Whose Products Exist in Array117
1190Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution117
1191Valid Triangle Number117
1192Web Crawler LeetCode Solution117
1193Maximum number of segments of lengths a, b and c116
1194First Bad Version116
1195Closest Leaf in a Binary Tree LeetCode Solution116
1196Kth Smallest Element in a BST116
1197Convert Sorted Array to Binary Search Tree LeetCode Solutions116
1198Maximum sum of pairs with specific difference116
1199Queue Reconstruction by Height116
1200Moving Stones Until Consecutive Leetcode Solution115
1201Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution115
1202Minimum Swaps To Make Sequences Increasing LeetCode Solution115
1203Guess The Word115
1204Given a binary tree, how do you remove all the half nodes?115
1205Array Queries for multiply replacements and product115
1206Concatenation of Array LeetCode Solution115
1207Integer Break LeetCode Solution115
1208Sum of Left Leaves LeetCode Solution114
1209Lowest Common Ancestor of a Binary Tree Leetcode Solution114
1210Range Sum Query using Sparse Table114
1211Divide Two Integers Leetcode Solution114
1212Perfect Squares LeetCode Solution113
1213Reformat Date LeetCode Solution113
1214Power of Two113
1215Champagne Tower LeetCode Solution113
1216Largest Plus Sign Leetcode Solution113
1217Replace two consecutive equal values with one greater113
1218Maximum Depth Of Binary Tree113
1219Print modified array after multiple array range increment operations112
1220Check Completeness of a Binary Tree LeetCode Solution112
1221New 21 Game112
1222Parallel Courses II LeetCode Solution112
1223Path Crossing Leetcode Solution112
1224Merge Sort112
1225Write a function to get the intersection point of two Linked Lists112
1226Longest Common Prefix Using Word by Word Matching112
1227Flatten 2D Vector LeetCode Solution112
1228Mean of range in array112
1229LRU Cache Leetcode Solution112
1230Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution112
1231Arithmetic Slices II – Subsequence LeetCode Solution112
1232Valid Perfect Square LeetCode Solution112
1233The kth Factor of n Leetcode Solution112
1234Maximum Value at a Given Index in a Bounded Array LeetCode Solution111
1235Sliding Window Median Leetcode Solution111
1236Find Minimum in Rotated Sorted Array II LeetCode Solution111
1237Print n terms of Newman-Conway Sequence111
1238Maximum sum of a path in a Right Number Triangle111
1239Range Queries for Longest Correct Bracket Subsequence111
1240Symmetric Tree LeetCode Solution Leetcode Solution111
1241Maximize Elements Using Another Array111
1242BST to a Tree with Sum of all Smaller Keys111
1243Bold Words in String LeetCode Solution111
1244Maximum Product Subarray110
1245Check if all levels of two Binary Tree are anagrams or not110
1246Check if each internal node of a BST has exactly one child110
1247Graph Cloning110
1248Check for Identical BSTs without building the trees110
1249Design Skiplist LeetCode Solution110
1250Queries on Probability of Even or Odd Number in given Ranges110
1251Missing Number109
1252Maximum Array from Two given Arrays Keeping Order Same109
1253Count Subsets Having Distinct Even Numbers109
1254Contiguous Array109
1255Image Overlap LeetCode Solution108
1256Find minimum number of merge operations to make an array palindrome108
1257Count and Toggle Queries on a Binary Array108
1258Smallest Range II Leetcode Solution108
1259Merge k Sorted Lists Leetcode Solution107
1260Koko Eating Bananas LeetCode Solution107
1261Number of elements less than or equal to a given number in a given subarray107
1262Print Ancestors of a Given Binary Tree Node Without Recursion107
1263Min Cost Climbing Stairs LeetCode Solution107
1264Excel Sheet Column Title LeetCode Solution107
1265Minimum Remove to Make Valid Parentheses LeetCode Solution106
1266Check If a String Can Break Another String Leetcode Solution106
1267Verify Preorder Serialization of a Binary Tree106
1268Palindrome Partitioning106
1269Find k-th smallest element in BST (Order Statistics in BST)106
1270Next greater element105
1271Peeking Iterator LeetCode Solution105
1272Different Ways to Add Parentheses Leetcode Solution105
1273Check if two nodes are on the same path in a Tree105
1274Orderly Queue LeetCode Solution103
1275Merge Sorted Array103
1276Minimum Time to Collect All Apples in a Tree LeetCode Solution103
1277Longest Substring Without Repeating Characters Leetcode Solution102
1278Check in binary array the number represented by a subarray is odd or even102
1279Newman–Shanks–Williams prime102
1280Arranging Coins Leetcode Solution101
1281Largest Submatrix With Rearrangements LeetCode Solution101
1282Check if X can give change to every person in the Queue101
1283Encoded String With Shortest Length LeetCode Solution100
1284Maximum Sum Increasing Subsequence98
1285Find maximum average subarray of k length98
1286Minimum Total Space Wasted With K Resizing Operations LeetCode Solution98
1287Queries for Decimal Values of Subarrays of a Binary Array97
1288Minimum Number of People to Teach LeetCode Solution97
1289Number of indexes with equal elements in given range97
1290Array Nesting Leetcode Solution97
1291Range Minimum Query (Square Root Decomposition and Sparse Table)97
1292Maximum product of an increasing subsequence96
1293Find the Winner of the Circular Game LeetCode Solution95
1294Binary Tree to Binary Search Tree Conversion using STL set95
1295Add Two Numbers II Leetcode Solution94
1296Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution94
1297Continuous Subarray Sum LeetCode Solution94
1298Convert a BST to a Binary Tree such that sum of all greater keys is added to every key94
1299Random Pick Index LeetCode Solution94
1300Check given array of size n can represent BST of n levels or not94
1301Convert to Base -2 LeetCode Solution94
1302Queries on XOR of greatest odd divisor of the range93
1303Jump Game IV LeetCode Solution93
1304Insert Delete GetRandom O(1) Leetcode Solution93
1305Reach a Number LeetCode Solution92
1306Palindrome Number LeetCode Solution91
1307Vertical Order Traversal of Binary Tree LeetCode Solution91
1308Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution91
1309Design Underground System Leetcode Solution89
1310Print Maximum Length Chain of Pairs86
1311Design A Leaderboard Leetcode Solution85
1312Detect Capital Leetcode Solution83
1313Substring with Concatenation of All Words Leetcode Solution82
1314Minimum Swaps to Group All 1’s Together Leetcode Solution80
1315Top K Frequent Elements LeetCode Solution79
1316Count Sub Islands LeetCode Solution78
1317Minimum Path Sum Leetcode Solution78
1318Binary Tree Inorder Traversal LeetCode Solution76
1319Best Meeting Point LeetCode Solution76
1320Longest Common Subsequence LeetCode Solution74
1321Decode String Leetcode Solution74
1322Shifting Letters LeetCode Solution74
1323Find the Town Judge LeetCode Solution73
1324Odd Even Linked List Leetcode Solution73
1325Maximum Population Year LeetCode Solution72
1326Sum Root to Leaf Numbers LeetCode Solution71
1327Shortest Unsorted Continuous Subarray LeetCode Solution71
1328Find the Town Judge LeetCode Solution71
1329Design Add and Search Words Data Structure LeetCode Solution68
1330Rectangle Overlap LeetCode Solution67
1331Maximum Population Year LeetCode Solution66
1332Score of Parenthesis LeetCode Solution65
1333Range Sum Query 2D – Immutable LeetCode Solution65
1334Insert into a Sorted Circular Linked List LeetCode Solution63
1335Flatten Binary Tree to Linked List LeetCode Solution63
1336Stone Game IV LeetCode Solution62
1337Is Graph Bipartite? LeetCode Solution62
1338Reveal Cards In Increasing Order Leetcode Solution62
1339Valid Triangle Number LeetCode Solution60
1340Divide Chocolate LeetCode Solution52
1341Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution47
1342Range Sum of BST LeetCode Solution45
1343Sort Colors LeetCode Solution42
1344Reverse Integer Leetcode Solution41
1345Find K Closest Elements LeetCode Solution38
1346Excel Sheet Column Number LeetCode Solution36
1347Rotate String LeetCode Solution36
1348Maximum Side Length of a Square with Sum Less than or Equal to Threshold LeetCode Solution35
1349Maximum Size Subarray Sum Equals k Leetcode Solution18
1350H-Index Leetcode Solution15
1351High Five LeetCode Solution14
Translate »