H-Index Leetcode Solution

Difficulty Level Medium
Frequently asked in Alation Amazon Apple Bloomberg Facebook Goldman Sachs Google Microsoft Nvidia
ArrayViews 2

Problem Statement:

H-Index Leetcode solution says that – Given an array of integers “citations” where citations[i] is the number of citations a researcher received for their ith paper, return researcher’s H-Index. If several H-Index values are present, return the maximum among them.

Definition of H-Index:  A scientist has an index “h” if h of their n papers have at least h citations each, and the other n-h papers have no more than h citations each.


citations = [3,0,6,1,5]


citations = [3, 0, 6, 1, 5] means there are  5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively. As the researcher has 3 papers with at least 3 citations (3, 6, 5) and the other remaining two with no more than 3 citations (0, 1). So the H-Index will be 3 in this case.


H-Index Leetcode SolutionPin

After replacing 6 with n = 5, we have citations = [3,0,5,1,5]. Now, we count the number of papers for each citation number 0 to . The counts are [1,1,0,1,0,2. The first k from right to left (5 down to ) that have k<=s is the h-index 3.


H-Index Leetcode SolutionPin

cutting off the area with citations more than n

Example 2:

citations = [1,3,1]
Output: 1




To solve this problem we use the Counting Sort technique with a little trick.

The idea is to see that the result can only range from 0 to the length of the array (because we can’t have an h-index greater than the total papers published).

  1. So we create an array “papers_freq” which acts like a HashMap and loops backward from the highest element.
  2.  Then we find “totalCitations ” which is the total number of papers that has more than i citations.
  3. We terminate when a total number of papers with more than i citations >= i  (totalCitations >=i ).
  4. We don’t need to keep going because we are trying the biggest i possible, we stop and return the result.



C++ code for H-Index Leetcode Solution :

class Solution {
    int hIndex(vector<int>& citations) {
        int len = citations.size();
        vector<int> papers_freq(len+1);
        for(int c: citations) {
            if(c > len) {
            } else {

        int totalCitations = 0;
        for(int i = len; i >= 0; i--) {
            totalCitations += papers_freq[i];
            if(totalCitations >= i) {
                return i;

        return -1;


Java code for H-Index Leetcode Solution :

class Solution {
    public int hIndex(int[] citations) {
        int len = citations.length;
        int[] papers_freq = new int[len+1];
        for(int c: citations) {
            if(c > len) {
            } else {

        int totalCitations = 0;
        for(int i = len; i >= 0; i--) {
            totalCitations += papers_freq[i];
            if(totalCitations >= i) {
                return i;

        return -1;

Complexity Analysis for H-Index Leetcoee Solution:

Time Complexity:

The Time Complexity will be O(N), first, we need to traverse the “citations” array once which needs O(N) time. Then for finding the H-Index we need another O(N) since we traverse the papers_freq array at most once. So, we can say that the overall time complexity of the code will be O(N).

Space Complexity:

Space Complexity will be O(N) since we use extra space to store the counts.

Top Interview Questions

S.No Interview Question Number of times has been asked
1Delete a node in doubly linked list2821
2Java program to find the number of Nodes in a Binary Tree2501
3Reverse a string without affecting special characters2464
4Delete a node of a linked list at given position1979
5Palindrome using Recursion1839
6Insert nodes in a linked list in a sorted way (Ascending Order)1662
7Find elements pair from array whose sum equal to number1650
8Sort Elements by Frequency of Occurrences1632
9Write a program to print all permutations of a given string1607
10Find Minimum Distance Between Two Numbers in an Array1477
11Create a Doubly Linked List1445
12Quick Sort1421
13Reverse an Array1414
14Smallest window in a string containing all characters of another string1396
15Find a Triplet That Sum to a Given Value1357
16Recursively remove all adjacent duplicates1356
17First Repeating Element1341
18Arrange Even and Odd number such that Odd comes after Even1325
19Sum of numbers in String1319
20Smallest Positive Number Missing in an Unsorted Array1285
21Check if the Elements of an Array are Consecutive1256
22Detect a loop in the Linked List1238
23Largest Sum Contiguous Subarray1232
24Quick Sort on SIngly Linked List1218
25Subarray with Given Sum1215
26Print all Possible Combinations of R Elements in a given Array of size N1207
27Recursive function to do substring search1197
28Find the Maximum Repeating Number in Array1157
29Binary Tree Level order traversal in Java1128
30Find the First and Second Smallest Elements1123
31Check if two linked lists are identical1104
32Maximum Subarray Sum using Divide and Conquer1099
33Remove characters from first string which are in second1070
34Find Leaders in an Array1063
35Swap nodes in the linked list1039
36Find the Number Occurring Odd Number of Times in an Array1005
37Arrange given Numbers to Form the Biggest Number II995
38Find the second most frequent character990
39Given a string find its first non-repeating character972
40Find Triplet in Array With a Given Sum965
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 list954
43A Program to check if strings are rotations of each other or not945
44Print all possible words from phone digits935
45Find the Missing Number927
46Rearrange Positive and Negative Numbers Alternatively in Array921
47Longest Palindromic Substring906
48Segregate even and odd nodes in a linked list883
49Print Longest common subsequence883
50Union and Intersection of Two Linked Lists874
51Transform one string to another using minimum number of given operations869
52Rearrange given Array in Maximum Minimum Form847
53Check rearranged string can form a palindrome847
54Count Possible Triangles821
55Iterative Implementation of Quick Sort816
56Multiplication of Two Matrices804
57Check if the linked list is palindrome796
58Rotate a Linked List795
59Count of Triplets With Sum Less than Given Value794
60Stock Buy Sell to Maximize Profit792
61Concatenation of two strings763
62Tug of War761
63Count Number of Substrings with K Distinct Character’s758
64Print all duplicates in the input string754
65Find Nearest Greater and Smaller Element748
66Find Pythagorean Triplets from Array739
67The Celebrity Problem738
68Reverse String Without Temporary Variable735
69Remove ‘b’ and ‘ac’ from a given string731
70Find all Common Elements in Given Three Sorted Arrays728
71Remove all duplicates in an unsorted linked list711
72Find the Row with Maximum Number of 1’s707
73Find the Peak Element from an Array703
74Find the subarray whose sum is equal to a given number X697
75Remove Minimum Characters so that Two Strings Become Anagrams690
76Find Smallest Missing Number in a Sorted Array689
77Addition of Two Matrices687
78A Product Array Puzzle687
79Insertion Sort686
80Implement Two Stacks in an Array679
81Generate all Binary Strings Without Consecutive 1’s678
82Maximum Sum of Non Consecutive Elements669
83Maximum Product Subarray II659
84Lexicographic rank of string655
85Check if Two given Matrices are Identical647
86Multiplication of Previous and Next644
87Subtraction of Two Matrices636
88Merge K Sorted Arrays and Print Sorted Output633
89Move All the Zeros to the End of the Given Array631
90Online Algorithm for Checking Palindrome in a Stream626
91Form Minimum Number from Given Sequence of D’s and I’s625
92Divide a string in N equal parts623
93Check whether two strings are anagram of each other615
94Maximum Circular Subarray Sum615
95Sort a linked list that is sorted alternating ascending and descending610
96Remove recurring digits in a given number610
97Sort a stack using a temporary stack609
98Find the Minimum Element in a Sorted and Rotated Array607
99Subarray and Subsequence602
100First Circular Tour to Visit all the Petrol Bunks602
101Move last element of the Linked List at first place601
102Largest Subarray with Equal Number of 0’s and 1’s599
103Flattening a linked list593
104Compare two strings(linked lists)592
105Maximum Element in an Array which is Increasing and then Decreasing590
106Palindrome Permutations of a String585
107Elements Appear more than N/K times in Array583
108Majority Element576
109Run length encoding575
110Palindromes in a given range573
111Minimum insertions to form a shortest palindrome573
112Print all permutations with repetition572
113Pangram Checking572
114Merge a linked list into another at alternate positions568
115Minimum Characters to be Added at Front to Make String Palindrome566
116Remove all duplicates in a sorted linked list565
117Rearrange a given linked list in-place564
118Minimum number of Merge Operations to make an Array Palindrome561
119Rotate string to get lexicographically minimum string558
120Most repeating character in a string558
121Repeated Subsequence of Length Two or More557
122Print all anagrams together in a sequence of words552
123Reorder an Array According to the Given Indexes551
124Pancake Sorting Problem543
125Merge Overlapping Intervals II539
126Two Sum Leetcode Solution539
127Clone a Linked List with next and random pointer538
128Size of The Subarray With Maximum Sum528
129Transpose of a Matrix525
130Removing Spaces from a String using stringstream522
131Remove duplicates from a string521
132Remove Extra Spaces from a String521
133Smallest Palindrome after Replacement520
134Check if a given string is a rotation of a palindrome519
135Partition Problem517
136Maximum Sum Increasing Subsequence517
137Longest Palindrome can be Formed by Removing or Rearranging Characters514
138Check whether Strings are K Distance Apart or Not504
139Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized504
140Generate all Binary Strings from Given Pattern502
141Delete Last Occurrence502
142Insert Node in the Sorted Linked List501
1433Sum Leetcode Solution500
144Length of Longest valid Substring499
145Check if Two given Strings are Isomorphic to each other494
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 not484
149Count Minimum Steps to Get the given Array481
150Number of Smaller Elements on Right Side480
151Merge sort better than quick sort for linked lists479
152Find Pair with Given Difference474
153Check length of a String is Equal to the Number Appended at its Last472
154Check if all Rows of a Matrix are Circular Rotations of Each Other471
155Find nth node of the Linked list from the end470
156Longest Common Prefix using Divide and Conquer470
157Find a Fixed Point in a Given Array464
158Sort 0s 1s and 2s in an Array463
159Print all interleavings of given two strings458
160Compare Two Version Numbers456
161Reverse words in a given string455
162Merge two sorted linked lists such that merged list is in reverse order454
163Find the Subarray of given length with Least Average453
164Reorder Array Using Given Indexes452
165Median of Two Sorted Arrays LeetCode Solution452
166Print Reverse of a string (Recursion)450
167Split linked list using alternate nodes450
168Find K Length Subarray of Maximum Average439
169Print string of odd length in ‘X’ format437
170Find Element Using Binary Search in Sorted Array434
171Swap Kth Node from beginning with Kth Node from End433
172Print all Palindromic Partitions of a String432
173Find Duplicates in an Array in Most Efficient Way429
174print all palindromic partitions422
175Maximum Length of Chain Pairs418
176Shortest Superstring Problem417
177Flatten a multilevel linked list416
178Check if String Follows Order of Characters by a Pattern or not413
179Sorting a K Sorted Array410
180Sort a String According to Another String404
181Longest Span with same Sum in two Binary Arrays II399
182Find a Sorted Subsequence of size 3396
183Reverse a Linked List in groups395
184Program to add two binary digits394
185Recursively print all the sentences that can be formed from list of word lists392
186Find the two Numbers with Odd Occurrences in an Unsorted Array390
187Longest Common Prefix Using Binary Search II385
188Reverse a Singly Linked List (Iterative/Non-Recursive)383
189Check if String can Become Empty by Recursively Deleting given Substring379
190Caesar Cipher379
191Kth Non-repeating Character379
192Rearrange a linked list in Zig-Zag378
193Pancake Sorting374
194Rotate Image by 90 degrees374
195Permutations of a Given String Using STL371
196Longest Common Prefix Word by Word Matching371
197Perfect Reversible String366
198Merging Two Sorted Arrays364
199Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes362
200Find the point where a monotonically increasing function becomes positive first time362
201Sort a linked list with 0s, 1s and 2s361
202Find First non-repeating character in a string361
203Increasing Subsequence of Length three with Maximum Product361
2041`s and 2`s complement of binary number358
205Four Elements that Sum to Given355
206Delete N nodes after M353
207List items containing all characters of a given word352
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 Alternate340
213Recursive Implementation of atoi()336
214Check if a Linked list of Strings form a Palindrome333
215Print All Distinct Elements of the Array332
216Convert a String that is Repetition of a Substring of Length K331
217Sorting the array of strings330
218Maximum occurring character in a string329
219Reverse a singly linked list recursively328
220Valid Parentheses LeetCode Solution328
221Even Substring Count328
222Can we reverse a linked list in less than O(n) time ?326
223Find the first Repeating Number in a Given Array326
224Print Shortest Path to Print a String on Screen323
225Binary Tree to Doubly linked list323
226Reverse a String using Stack322
227Convert string1 to string2 in one edit321
228Maximum Subarray Leetcode Solution320
229Nth Character in Concatenated Decimal String319
230wildcard character matching319
231Sort Elements by Frequency II318
232Lower Case To Upper Case316
233Count the number of words313
234Split Four Distinct Strings311
235Merge Two Sorted Arrays311
236Find the Lost Element From a Duplicated Array310
237Find middle of the Linked List308
238Longest Common Subsequence with Permutations306
239Count the Pairs at Same Distance as in English Alphabets301
240Matrix Chain Multiplication using Dynamic Programming298
241Next Greater Element in an Array295
242Palindrome Permutation290
243Roman to Integer Leetcode Solution287
244Find Nth Node285
245Find All Pairs With a Given Difference284
246Searching a node in a Binary Search Tree283
247Triplet from three linked lists with given sum281
248String(represents an integer) to value280
249Delete a Tree280
250Reverse a String278
251Print all Possible Ways to Break a String in Bracket Form277
252Reverse Bits276
253Word Search Leetcode Solution275
254Binary Tree274
255Delete a node under given conditions273
256How to Efficiently Implement k Stacks in a Single Array?273
257Change Gender of a given String273
258Sort an array of strings272
259Meeting Rooms II LeetCode Solution270
260Count Pairs With Given Sum269
261Number of sub-strings which recursively add up to 9269
262Longest Common Extension268
263First non Repeating Element268
264Repeated Substring Pattern268
265Remove middle points in a linked list of line segments266
266Toeplitz Matrix265
267Move all negative elements to one side of array265
268Longest Palindromic Substring LeetCode Solution264
269Remove spaces from a string263
270Min Stack261
271Shuffle a given Array260
272N queen problem259
273Number of Islands LeetCode Solution254
274Cuckoo sequence program253
275House Robber Leetcode Solution252
276Find, second, frequent, character252
277Dijkstra Algorithm252
278Minimize the maximum difference between the heights251
279Clone a linked list with next and random pointer (Hashing)249
280Max stack249
281Search Insert Position Leetcode Solution248
282Most Frequent Element in an Array248
283Sort linked which is sorted on absolute values246
284Expression Evaluation245
285KMP Algorithm244
286Subset Leetcode244
287Fibonacci numbers243
288Valid Palindrome Leetcode Solution243
289Plus One Leetcode Solution242
290Min Stack Leetcode Solution242
291Number Of 1 bits242
292Sudoku Solver241
293Reverse words in a string241
294How to Delete a Linked List241
295Evaluation of Postfix Expression240
296Word Search239
297Combination Sum Leetcode Solution238
298Backspace String Compare234
299Merge Sorted Arrays Leetcode Solution234
300Sqrt(x) Leetcode Solution232
301Reversing a Queue231
302Subarray with 0 sum231
303Set Matrix Zeroes231
304Pair of Positive Negative Values in an Array229
305Rabin Karp Algorithm228
306Product of array except self228
307Contains Duplicate II Leetcode Solution228
308Combination Sum226
309Tower Of Hanoi226
310Common elements in all rows of a given matrix225
311Delete middle element of a stack225
312Pascal Triangle Leetcode224
313Intersection of Two Arrays II Leetcode Solution224
314Integer to Roman Leetcode Solution224
315String Compression223
316Minimum swaps required to bring all elements less than or equal to k together221
317Reverse individual words221
318Count subarrays with equal number of 1’s and 0’s221
319Single Number Leetcode Solution219
320Find Top K (or Most Frequent) Numbers in a Stream219
321Add Binary Leetcode Solution218
322Implementation of Deque using Doubly Linked List218
323Arithmetic Expression Evaluation218
324Sliding Window Technique218
325Segregate even and odd numbers217
326Count of index pairs with equal elements in an array217
327Bellman Ford Algorithm217
328Pow(x, n) Leetcode Solution217
329Palindrome Linked List Leetcode Solution216
330Second Most Repeated Word in a Sequence216
331Construct Binary Tree from Given Inorder and Preorder Traversals216
332Count Odd Numbers in an Interval Range Leetcode Solution215
333Design a stack that supports getMin() in O(1) time and O(1) extra space215
334Contains Duplicate215
335Next Permutation214
336Postfix to Infix Conversion214
337Page Replacement Algorithms in Operating Systems214
338Third Maximum Number Leetcode Solution214
339Maximum Number of Balloons Leetcode Solution213
340Minimum Value to Get Positive Step by Step Sum Leetcode Solution213
341Kruskal Algorithm212
342Convex Hull Algorithm211
343Sort elements by frequency210
344Group Words With Same Set of Characters210
345Find sum of non-repeating elements (distinct) elements in an array210
346K-th Smallest Element in a Sorted Matrix210
347Permutations Leetcode Solution210
348Longest Common Prefix Leetcode Solution209
349Find Lucky Integer in an Array Leetcode Solution209
350Find the Town Judge Leetcode Solution209
351Longest Substring Without Repeating Characters LeetCode Solution208
352Majority Element Leetcode Solution207
353Spiral Matrix LeetCode Solution207
354Sum of minimum and maximum elements of all subarrays of size k207
355Top K Frequent Words206
356Maximum Subarray206
357Evaluate Division206
358Find Numbers with Even Number of Digits Leetcode Solution206
359Sorting array using Stacks205
360Scramble String205
361Prefix to Infix Conversion205
362Minimum operation to make all elements equal in array205
363Count subarrays having total distinct elements same as original array204
364Smallest Subarray with k Distinct Numbers204
365Swap Nodes in Pairs Leetcode Solutions204
366Number of Good Pairs Leetcode Solution204
367Special Number203
368First element occurring k times in an array203
369Count Primes Leetcode Solutions203
370Minimum Path Sum203
371Given two unsorted arrays find all pairs whose sum is x203
372Best Time to Buy and Sell Stock  II Leetcode Solution202
373Merge Two Sorted Lists Leetcode Solutions202
374Check if two arrays are equal or not202
375Sort Array by Increasing Frequency Leetcode Solution201
376Missing Number Leetcode Solution201
377Search in Rotated Sorted Array Leetcode Solution201
378Pascal’s Triangle II Leetcode Solution201
379Power of Two Leetcode Solution201
380Find All Numbers Disappeared in an Array Leetcode Solution200
381Huffman Coding200
382Reverse a Number Using Stack200
383Minimum Steps to reach target by a Knight199
384House Robber II Leetcode Solution199
385Fizz Buzz Leetcode199
386Reversing the First K elements of a Queue198
387Unique Paths Leetcode Solution198
388Top K Frequent Elements198
389Group Anagrams198
390Maximal Square198
391Running Sum of 1d Array Leetcode Solution198
392Minimum Absolute Difference Leetcode Solution198
393How to Implement Stack Using Priority Queue or Heap?197
394Find duplicates in a given array when elements are not limited to a range197
395Matrix Diagonal Sum Leetcode Solution197
396Maximum possible difference of two subsets of an array197
397Leetcode Permutations197
398Coin Change 2 Leetcode Solution196
399How Many Numbers Are Smaller Than the Current Number Leetcode Solution196
400Sort Integers by The Number of 1 Bit Leetcode Solution196
401Single Number196
402Range Sum Query 2D – Immutable Leetcode Solution196
403Find Minimum In Rotated Sorted Array196
404Find Number of Employees Under every Employee195
405Happy Number Leetcode Solution195
406Zigzag Conversion195
407Maximum Distance Between two Occurrences of Same Element in Array195
408Max Consecutive Ones Leetcode Solution195
409Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution195
410Sorting using trivial hash function194
411Expression Contains Redundant Bracket or Not194
412Check if Array Contains Contiguous Integers With Duplicates Allowed194
413Unique Paths193
414Subarray Sum Equals K LeetCode Solution193
415Subarray Sum Equals k193
416Convert String To Int193
417Remove Duplicates from Sorted Array Leetcode Solution193
418Find The Duplicate Number193
419Decode String193
420Reverse Vowels of a String Leetcode Solution192
421Length of the largest subarray with contiguous elements192
422Best Time to Buy and Sell Stock III Leetcode Solution192
423Difference between highest and least frequencies in an array192
424Smallest Element Repeated Exactly K Times192
425Fibonacci Number LeetCode Solution192
426Find the Closest Palindrome number192
427Find Winner on a Tic Tac Toe Game Leetcode Solution191
428Implement Stack and Queue using Deque191
429Subtract the Product and Sum of Digits of an Integer Leetcode Solution191
430Check If N and Its Double Exist Leetcode Solution191
431Subset sum problem191
432Reverse Integer191
433Monotonic Array LeetCode Solution190
434Shuffle the Array Leetcode Solution190
435Maximum Depth of Binary Tree Leetcode Solution190
436Find Median from data Stream190
437Delete a Node from linked list without head pointer189
438Reverse a Stack Using Recursion189
439Cumulative Frequency of Count of Each Element in an Unsorted Array189
440Find top three repeated in array189
441LRU Cache Implementation189
442Nth Catalan Number189
443Palindrome Substring Queries189
444Trapping Rain Water Leetcode Solution189
445Subarrays with distinct elements188
446Find the Duplicate Element188
447Print All Distinct Elements of a Given Integer Array188
448Capacity To Ship Packages Within D Days Leetcode Solution188
449Reverse Words in a String III LeetCode Solution188
450Kth largest element in an Array Leetcode Solutions188
451Count Substrings with equal number of 0s, 1s and 2s188
452Letter Case Permutation188
453Generate a String With Characters That Have Odd Counts Leetcode Solution188
454Integer to English words187
455The K Weakest Rows in a Matrix Leetcode Solution187
456Minimum Moves to Equal Array Elements Leetcode Solution187
457Priority Queue Using Singly Linked List187
458Find all pairs (a, b) in an array such that a % b = k186
459Sort a stack using recursion186
460Find the first repeating element in an array of integers186
461Sorting a Queue without Extra Space186
462Find Common Characters Leetcode Solution186
463Excel Sheet Column Number Leetcode Solution186
464Bipartite Graph186
465Concatenation of Array LeetCode Solution185
466Count pairs from two linked lists whose sum is equal to a given value185
467Find First and Last Position of Element in Sorted Array Leetcode Solution185
468Iterative Tower of Hanoi185
469Next Greater Element I Leetcode Solution185
470Floyd Warshall Algorithm185
471Merge Two Sorted Linked Lists185
472Word Ladder LeetCode Solution185
473Target Sum185
474Fizz Buzz184
475Longest Common Subsequence184
476Balanced Binary Tree Leetcode Solution184
477Text Justification LeetCode Solution184
478Prim’s Algorithm184
479Reverse a String184
480Multiply Strings Leetcode Solution184
481Find elements which are present in first array and not in second183
482Print all subarrays with 0 sum183
483Merge Overlapping Intervals183
484Kids With the Greatest Number of Candies Leetcode Solution183
485Find the Difference Leetcode Solution183
486Edit Distance183
487Sum of Subarray Ranges Leetcode Solution182
488Degree of an array182
489Flood Fill LeetCode182
490Slowest Key Leetcode Solution182
491Kth Largest Element in a Stream Leetcode Solution182
492Count and Say182
493Reverse a linked list182
494Move Zeroes LeetCode Solution182
495Remove Minimum Number of Elements Such That no Common Element Exist in both Array182
496MiniMax Algorithm181
497Number of Steps to Reduce a Number to Zero Leetcode Solution181
498Zigzag Conversion LeetCode Solution181
499Implement a stack using single queue181
500Design Parking System Leetcode Solution181
501Longest Common Prefix using Trie181
502Length of Last Word Leetcode Solution181
503Top View of Binary Tree181
504Substring With Concatenation Of All Words180
505Jump Game Leetcode Solution180
506Intersection of Two Arrays180
507Pair with given product179
508The Stock Span Problem179
509Count and Say Leetcode Solution179
510Valid Parenthesis String179
511Peak Index in a Mountain Array179
512Convert array into Zig-Zag fashion179
513Find subarray with given sum (Handles Negative Numbers)179
514Contiguous Array Leetcode178
515Find N Unique Integers Sum up to Zero Leetcode Solution178
516Max Area of Island178
517Last Stone Weight178
518Find four elements that sum to a given value (Hashmap)178
519Longest subarray not having more than K distinct elements178
520Mobile Numeric Keypad Problem178
521Postfix to Prefix Conversion178
522Priority Queue in C++178
523Delete Node in a Linked List Leetcode Solution177
524Check if a given array contains duplicate elements within k distance from each other177
525Shuffle String Leetcode Solution177
526N-th Tribonacci Number Leetcode Solution177
527Koko Eating Bananas Leetcode Solution177
528Prefix to Postfix Conversion177
529Find missing elements of a range177
530Longest Common Prefix using Sorting177
531Shortest Palindrome176
532Largest Perimeter Triangle Leetcode Solution176
533Find Index of Closing Bracket for a Given Opening Bracket in an Expression176
534Relative Sort Array Leetcode Solution176
535K-th Distinct Element in an Array175
536Isomorphic Strings Leetcode Solution175
537Find distinct elements common to all rows of a matrix175
538Best Time to Buy and Sell Stock175
539Iterative Inorder Traversal of a Binary Tree175
540Smallest Subarray With all Occurrences of a Most Frequent Element174
541Count number of triplets with product equal to given number174
542Is Subsequence Leetcode Solution174
543Implementation of Deque using circular array174
544First negative integer in every window of size k174
545Minimum Operations to convert X to Y174
546Implement Stack using Queues174
547Change the Array into Permutation of Numbers From 1 to N174
548Build Array From Permutation Leetcode Solution174
549Excel Sheet Column Title Leetcode Solution174
550Container with Most Water174
55101 Matrix LeetCode Solution174
553Find any one of the multiple repeating elements in read only array174
554Hamming Distance173
555Convert Sorted Array to Binary Search Tree Leetcode Solution173
556Jewels and Stones Leetcode Solution173
557Maximum sum rectangle in a 2D matrix173
558Distribute Candies to People Leetcode Solution173
559Convert a normal BST to Balanced BST173
560Remove Linked List Elements Leetcode Solution173
561Island Perimeter Leetcode Solution173
562Valid Sudoku173
563Valid Anagrams173
564Find the smallest positive integer value that cannot be represented as sum of any subset of a given array172
565Sum of Left Leaves Leetcode Solutions172
566Next Greater Frequency Element172
567Shuffle an Array172
568Linked List Cycle II LeetCode Solution172
569Arrange given numbers to form the biggest number171
570Assign Cookies Leetcode Solution171
571Find Words That Can Be Formed by Characters Leetcode Solution171
572Count the number of nodes at given level in a tree using BFS171
573Minimum Delete Operations to make all Elements of Array Same171
574Check for Balanced Parentheses in an Expression171
575Insert Interval Leetcode Solution171
576Trapping Rain Water LeetCode Solution171
577Shortest Path in a Grid with Obstacles Elimination LeetCode Solution170
5783Sum Closest LeetCode Solution170
579Maximum path sum in a triangle170
580Rotate List Leetcode Solution170
581Rearrange a binary string as alternate x and y occurrences170
582Summary Ranges Leetcode Solution170
583Count all subsequences having product less than K170
584Maximum Number of Chocolates to be Distributed Equally Among k Students170
585Minimum Bracket Reversals170
586Group Multiple Occurrence of Array Elements Ordered by first Occurrence170
587Rotate Image LeetCode Solution170
588Gold Mine Problem170
589Minimum number of distinct elements after removing m items169
590Distance Between Bus Stops Leetcode Solution169
591The Knapsack Problem169
592Combinations Leetcode Solution169
593LRU Cache LeetCode Solution169
594Permutation in String Leetcode Solution169
595Integer to Roman169
596Unique Binary Search Trees168
597Maximum Distance in Array168
598K Empty Slots LeetCode168
599Same Tree LeetCode Solution168
600Decode Ways168
601Minimum Knight Moves LeetCode Solution168
602How to check if two given sets are disjoint?168
603XOR Operation in an Array Leetcode Solution167
604Distance of nearest cell having 1 in a binary matrix167
605Printing brackets in Matrix Chain Multiplication Problem167
606Segregate 0s and 1s in an Array167
607Sieve of Eratosthenes167
608Remove All Occurrences of a Substring LeetCode Solution167
609Replace Elements with Greatest Element on Right Side Leetcode Solution167
610Find the Duplicate Number LeetCode Solution166
611Stone Game LeetCode166
612Find if an Expression has Duplicate Parenthesis or Not166
613Sort Characters By Frequency LeetCode Solution166
614License Key Formatting Leetcode Solution166
615Best Time to Buy and Sell Stock LeetCode Solution166
616Sort Array By Parity LeetCode Solution166
617Word Wrap Problem166
618Applications of Breadth First Search and Depth First Search165
619Maximum difference between first and last indexes of an element in array165
620Minimum number of subsets with distinct elements165
621Minimum insertions to form a palindrome with permutations allowed165
622Find Sum of all unique sub-array sum for a given array165
623Frog Jump Leetcode Solution165
624Word Pattern165
625Find minimum difference between any two elements165
626Maximum Consecutive Numbers Present in an Array164
627Defanging an IP Address Leetcode Solution164
628Smallest Good Base164
629Painting Fence Algorithm164
630Queries for counts of array elements with values in given range163
631Find pairs with given sum such that elements of pair are in different rows163
632GCD Of Two Numbers163
633Tracking current Maximum Element in a Stack163
634Find Maximum Level sum in Binary Tree163
635House Robber163
636Longest Substring with At Most K Distinct Characters LeetCode Solution163
637Minimum Depth of Binary Tree Leetcode Solution163
638Best Time to Buy and Sell Stock with Cooldown Leetcode Solution163
639Binary Tree Zigzag Level Order Traversal LeetCode Solution163
640Check If It Is a Straight Line Leetcode Solution163
641Non-overlapping sum of two sets162
642Minimum Cost to Hire K Workers162
643Isomorphic Strings162
644Valid Palindrome II Leetcode Solution162
645Employee Free Time LeetCode Solution162
646Kth Missing Positive Number Leetcode Solution162
647Strobogrammatic Number LeetCode Solution162
648Coin Change Problem162
649Iterative Method to find Height of Binary Tree162
650Maximum Number of Coins You Can Get Leetcode Solution162
651Optimal Account Balancing LeetCode Solution162
652Print the Fibonacci numbers in reverse order162
653Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions161
654Letter Combinations of a Phone Number161
655Longest Substring with At Least K Repeating Characters LeetCode Solution161
656Delete consecutive same words in a sequence161
657Wiggle Sort161
658Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest161
659Number of Provinces Leetcode Solution161
660Longest Increasing Subsequence161
661Count Good Nodes in Binary Tree Leetcode Solution161
662Reverse a stack without using extra space in O(n)160
663Moving Average from Data Stream Leetcode Solution160
664Ugly Number Leetcode Solution160
665Merge Two Balanced Binary Search Trees160
666Power of Four Leetcode Solution160
667K Empty Slots160
668Partition Labels LeetCode Solution160
669Longest Increasing Path in a Matrix LeetCode Solution160
670Maximum Number of Occurrences of a Substring Leetcode Solution160
671Number of Dice Rolls With Target Sum LeetCode Solution160
672Sum of All Odd Length Subarrays Leetcode Solution160
673Find the Distance Value Between Two Arrays Leetcode Solution159
674Check If Two String Arrays are Equivalent Leetcode Solution159
675Convert an array to reduced form159
676BFS vs DFS for Binary Tree159
677Form minimum number from given sequence159
678Sort Array by Increasing Frequency Leetcode Solution159
679Valid Perfect Square Leetcode Solution159
680Edit Distance LeetCode Solution158
681String to Integer (atoi) LeetCode Solution158
682Check if a queue can be sorted into another queue using a stack158
683Flipping an Image LeetCode Solution158
684Reducing Dishes LeetCode Solution158
685Find the Smallest Divisor given a Threshold Leetcode Solution158
686Path With Maximum Minimum Value LeetCode Solution158
687Reverse Only Letters LeetCode Solution158
688Largest Sum Contiguous Subarray158
689Remove Invalid Parentheses Leetcode Solution158
690Unique Paths II Leetcode Solution158
691How to Create Mergable Stack?157
692Robot Room Cleaner Leetcode Solution157
693Merge Two Binary Trees LeetCode Solution157
694Populating Next Right Pointers in Each Node157
695Maximum Product of Two Elements in an Array Leetcode Solution157
696Binary Tree zigzag level order Traversal157
697Permutation Sequence LeetCode Solution157
698Construct BST from given Preorder Traversal157
699Find Leaves of Binary Tree LeetCode Solution157
700Convert a Number to Hexadecimal Leetcode Solution157
701To Lower Case Leetcode Solution157
702Increasing Decreasing String Leetcode Solution157
703Reversing a Queue using Recursion157
704Lucky Numbers in a Matrix Leetcode Solution157
705Reorganize String157
706Reservoir Sampling157
707Delete Nth node from the end of the given linked list157
708Find Largest d in Array such that a + b + c = d157
709Sum of f(a[i], a[j]) over all pairs in an array of n integers157
710Inorder Successor of a node in Binary Tree157
711Find whether an array is subset of another array157
712Dynamic Programming Basics157
713Subset Sum Leetcode157
714Partition Array Into Three Parts With Equal Sum Leetcode Solution156
715Keyboard Row Leetcode Solution156
716Restore IP Addresses Leetcode Solution156
717Majority Element II Leetcode Solution156
718Recover Binary Search Tree156
719Factorial Trailing Zeroes Leetcode Solution156
720Valid Palindrome156
721Add and Search Word – Data structure design LeetCode155
722Bulb Switcher LeetCode Solution155
723Decompress Run-Length Encoded List Leetcode Solution155
724Find the node with minimum value in a Binary Search Tree155
725Hamming Distance Leetcode Solution154
726Search a 2D Matrix II Leetcode Solution154
727Maximum Product of Three Numbers LeetCode Solution154
728Student Attendance Record I Leetcode Solution154
729Rank Transform of an Array Leetcode Solution154
730Finding K closest element154
731First Unique Character in a String LeetCode Solution154
732Minimum Distance Between BST Nodes Leetcode Solution153
733Minimum Cost For Tickets Leetcode Solution153
734Sorted Linked List to Balanced BST153
735Evaluate Reverse Polish Notation LeetCode Solution153
736Find the largest multiple of 3153
737Morris Traversal153
738Invert Binary Tree LeetCode Solution153
739Symmetric Tree Leetcode Solution153
740Find Median from Data Stream LeetCode Solution153
741Word Pattern LeetCode Solution153
742Bubble sort using two Stacks153
743String Compression LeetCode Solution153
744Find unique character in a string153
745Maximum 69 Number Leetcode Solution153
746Stack Permutations (Check if an array is stack permutation of other)153
747Queue based approach for first non-repeating character in a stream153
748Diagonal Traversal of Binary Tree153
749Numbers with prime frequencies greater than or equal to k153
750Maximum Depth of N-ary Tree Leetcode Solution153
751Perform String Shifts Leetcode152
752Largest rectangular sub-matrix whose sum is 0152
753Longest Span with same Sum in two Binary arrays152
754Number of Islands II LeetCode Solution152
755Generate all possible sorted arrays from alternate elements of two given sorted arrays152
756Largest subarray with equal number of 0s and 1s152
757Best Meeting Point LeetCode Solution152
758Non-decreasing Array LeetCode Solution152
759Snakes and Ladders LeetCode Solution152
760Maximum Length of a Concatenated String with Unique Characters Leetcode Solution152
761Binary Tree Maximum Path Sum LeetCode Solution152
762Binomial Coefficient152
763Find All Duplicates in an Array LeetCode Solution152
764Minimum Height Trees152
765Search in a Binary Search Tree Leetcode Solution152
766Deletion in a Binary Tree152
767Elements to be added so that all elements of a range are present in array152
768k-th missing element in increasing sequence which is not present in a given sequence151
769Find Maximum Depth of Nested Parenthesis in a String151
770Largest Rectangle in Histogram LeetCode Solution151
771Remove Duplicates from Sorted List LeetCode Solution151
772N-Queens LeetCode Solution151
773Split a String in Balanced Strings Leetcode Solution151
774Jump Game151
775Race Car LeetCode Solution151
776Kth ancestor of a node in binary tree151
777Merge K Sorted Linked Lists151
778Check If Array Pairs Are Divisible by k LeetCode Solution151
779Linked List Cycle151
780Minimum number of jumps to reach end150
781Find if Path Exists in Graph Leetcode Solution150
782Maximum Difference Between Increasing Elements LeetCode Solution150
783Remove Nth Node From End of List Leetcode Solution150
784Find Pair with Greatest Product in Array150
785Minimize Maximum Pair Sum in Array LeetCode Solution150
786Final Prices With a Special Discount in a Shop Leetcode Solution150
787Count quadruples from four sorted arrays whose sum is equal to a given value x150
788Special Array With X Elements Greater Than or Equal X Leetcode Solution150
789Transpose Graph150
790Alien Dictionary LeetCode Solution149
791Growable array based stack149
792Relative Ranks Leetcode Solution149
793Number of NGEs to the Right149
794Can Place Flowers LeetCode Solution149
795Nearest Exit from Entrance in Maze LeetCode Solution149
796Nested List Weight Sum II LeetCode Solution148
797Merge Sorted Array LeetCode Solution148
798Interval Tree148
799Get Maximum in Generated Array Leetcode Solution148
800Check for Palindrome after every character replacement Query148
801Minimum time required to rot all oranges148
802Tiling Problem148
803Check if Two Expressions With Brackets are Same148
804Print a Binary Tree in Vertical Order148
805Valid Number148
806Minimum Jumps to Reach Home LeetCode Solution148
807Sort an array according to the order defined by another array148
808Remove brackets from an algebraic string containing + and – operators148
809String comparison containing wildcards148
810Program for Bridge and Torch problem148
811Minimum Time Visiting All Points Leetcode Solution148
812Crawler Log Folder Leetcode Solution148
813Convert BST to Min Heap148
814Number Complement Leetcode Solution148
815Friends Pairing Problem147
816Total Numbers With no Repeated Digits in a Range147
817Sort Colors147
818Subarray Product Less Than K LeetCode Solution147
819Check if a given array can represent Preorder Traversal of Binary Search Tree147
820Count items common to both the lists but with different prices147
821Regular Expression Matching147
822Sort Array By Parity II Leetcode Solution147
823Top K Frequent Words LeetCode Solution147
824Base 7 Leetcode Solution147
825Partition to K Equal Sum Subsets Leetcode Solution147
826Reorder Data in Log Files LeetCode Solution147
827Priority Queue using doubly linked list147
828Find the Only Repetitive Element Between 1 to N-1147
829Remove Duplicates from Sorted List II147
830Maximum Profit in Job Scheduling Leetcode Solution147
831Design a Stack With Increment Operation Leetcode Solution147
832One Edit Distance LeetCode Solution147
833Maximum size subarray sum equals k147
834Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution147
835A Space Optimized DP solution for 0-1 Knapsack Problem147
836Longest Subarray Having Count of 1s One More than Count of 0s146
837Minimum swaps to make sequences increasing146
838Circular Queue146
839Minimum Number of Taps to Open to Water a Garden LeetCode Solution146
840Path with maximum average value146
841Partition List Leetcode Solution145
842Sorted Array to Balanced BST145
843Guess Number Higher or Lower LeetCode Solution145
844Given an Array of Pairs Find all Symmetric Pairs in it145
845Brightest Position on Street LeetCode Solution145
846Find the subarray with least average145
847Clone Graph LeetCode Solution145
848Subset with sum divisible by m145
849Binary Search Tree Search and Insertion145
850Subsequence of Size K With the Largest Even Sum LeetCode Solution145
851Check if an Array is Stack Sortable144
852Three way partitioning of an array around a given range144
853Level order Traversal in Spiral Form144
854Iterative Preorder Traversal144
855Brick Wall LeetCode Solution144
856Repeated Substring Pattern LeetCode Solution144
857Insert into a Binary Search Tree Leetcode Solution144
858Course Schedule II – LeetCode144
859Tree Traversal (Preorder, Inorder & Postorder)144
860Maximum Nesting Depth of the Parentheses Leetcode Solution144
861Valid Parentheses Leetcode Solution144
862Find All Possible Recipes from Given Supplies LeetCode Solution144
863Minimum Sum Path in a Triangle144
864Last Stone Weight II LeetCode Solution144
865Count Distinct Elements in Every Window of Size K144
866Sum of nearest smaller and greater number144
867Minimum Swaps to Make Strings Equal Leetcode Solution144
868Union and Intersection of two Linked Lists144
869Find all triplets with zero sum143
870Permutation Coefficient143
871Water Bottles Leetcode Solution143
872Check whether a given Binary Tree is Complete or not143
873Daily Temperatures Leetcode Solution143
874Count ways to reach the nth stair using step 1, 2 or 3143
875Rearrange Spaces Between Words Leetcode Solution143
876LCS (Longest Common Subsequence) of three strings142
877Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution142
878Missing Element in Sorted Array LeetCode Solution142
879Spiral Matrix II Leetcode Solution142
881Destination City Leetcode Solution142
882Balanced Expression with Replacement142
883Range sum queries without updates142
884Robot Bounded In Circle LeetCode Solution142
885Lemonade Change Leetcode Solution142
886GCDs of given index ranges in an array142
887Guess Number Higher or Lower II142
888Least Number of Unique Integers after K Removals Leetcode Solution142
889Form Minimum Number From Given Sequence142
890Number of Days Between Two Dates LeetCode Solution142
891Sequences of given length where every element is more than or equal to twice of previous142
892Matrix Chain Multiplication142
893Count Negative Numbers in a Sorted Matrix LeetCode Solution142
894Identify and Mark Unmatched Parenthesis in an Expression141
895Minimum sum of multiplications of n numbers141
896Design Browser History LeetCode Solution141
897BFS for Disconnected Graph141
898Queries for GCD of all numbers of an array except elements in a given range141
899An Interesting Method to generate Binary Numbers from 1 to n141
900Delete And Earn141
901Palindrome Partitioning Leetcode Solution141
902Maximum Score After Splitting a String Leetcode Solution140
903Convert Sorted List to Binary Search Tree140
904Spiral Matrix III LeetCode Solution140
905Find Maximum Sum Possible Equal Sum of Three Stacks140
906Intersection of Two Linked Lists LeetCode Solution140
907Diagonal Traversal LeetCode Solution140
908Strongly Connected Component140
909Time Based Key-Value Store LeetCode Solution140
910Find distance between two nodes of a Binary Tree140
911Distinct adjacent elements in an array140
912Shortest Word Distance Leetcode Solution140
913Special Positions in a Binary Matrix Leetcode Solution140
914Find all permuted rows of a given row in a matrix140
915Check if the given array can represent Level Order Traversal of Binary Search Tree140
916Count Subarrays with Same Even and Odd Elements140
917Insert Delete GetRandom140
918Construct Complete Binary Tree from its Linked List Representation140
919Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i139
920Find Common Characters Leetcode Solution139
921Lexicographical Numbers Leetcode Solution139
922Diagonal Traverse LeetCode Solution139
923Remove Duplicates from Sorted List II LeetCode Solution139
924Trim a Binary Search Tree139
925Rearrange an Array Such that arr[i] is equal to i139
926A program to check if a binary tree is BST or not139
927Merge Two Sorted Lists Leetcode139
928Alien Dictionary139
929Check if stack elements are pairwise consecutive139
930Set Matrix Zeroes Leetcode Solution139
931Word Break138
932Iterative Postorder Traversal Using Two Stacks138
933Analyze User Website Visit Pattern LeetCode Solution138
934Longest Palindromic Subsequence138
9353 Sum138
936Number of Distinct Islands Leetcode Solution138
937Merging Intervals138
938Maximum Frequency Stack Leetcode Solution138
939K’th Largest Element in BST when modification to BST is not allowed138
940Range LCM Queries138
941Print Fibonacci sequence using 2 variables138
942Vertical sum in a given binary tree138
943Collect maximum points in a grid using two traversals138
944Count Submatrices With All Ones LeetCode Solution137
945All Unique Triplets that Sum up to a Given Value137
946Construct BST from its given Level Order Traversal137
947Count pair with Given Sum137
948Queue using Stacks137
949Construct the Rectangle Leetcode Solution137
950Infix to Postfix137
951Longest Nice Substring LeetCode Solution137
952Can Make Arithmetic Progression From Sequence Leetcode Solution137
953Three Consecutive Odds Leetcode Solution137
954Stone Game II Leetcode137
955Binary Tree Longest Consecutive Sequence LeetCode Solution136
956Number of Equivalent Domino Pairs Leetcode Solution136
957Maximize Sum of Array after K Negations Leetcode Solution136
958Minimum Height Trees LeetCode Solution136
959Dividing Array into Pairs With Sum Divisible by K136
960Largest area rectangular sub-matrix with equal number of 1’s and 0’s136
961Maximum Subarray Sum Excluding Certain Elements136
962Sliding Window Maximum136
963Reverse Nodes in K-Group136
964Level order traversal using two Queues136
965Averages of Levels in Binary Tree136
966Palindrome Partitioning136
967Product of Array Except Self LeetCode Solution136
968Check if any two intervals overlap among a given set of intervals135
969Count Primes in Ranges135
970K Closest Points to Origin Leetcode Solution135
971Maximum Product of Indexes of Next Greater on Left and Right135
972Binary array after M range toggle operations135
973Breadth First Search (BFS) for a Graph135
974Difference Array | Range update query in O(1)135
975Pattern Occurrences using Stack135
976Find postorder traversal of BST from preorder traversal135
977Median of Two Sorted Arrays135
978Asteroid Collision LeetCode Solution135
979Split Array Into Consecutive Subsequences135
980Create Maximum Number135
981Find Maximum of Minimum for Every Window Size in a Given Array134
982Level Order Traversal of Binary Tree134
983Maximum subsequence sum such that no three are consecutive134
984Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution134
985Minesweeper LeetCode Solution134
986Height of a generic tree from parent array134
987Newman-Conway Sequence134
988Segment Tree134
989Kth Smallest Element in a BST Leetcode Solution134
990Largest divisible pairs subset134
991Symmetric Tree134
992The Maze III LeetCode Solution134
993Maximum Product Subarray134
994Largest Substring Between Two Equal Characters Leetcode Solution134
995Depth First Search (DFS) for a Graph133
996Find Duplicate Subtrees133
997Serialize and Deserialize Binary Tree133
998Length of Longest Fibonacci Subsequence133
999Decrypt String from Alphabet to Integer Mapping Leetcode Solution133
1000The Painter’s Partition Problem133
1001Build an Array With Stack Operations Leetcode Solution133
1002Friends Of Appropriate Ages LeetCode Solution133
1003Rearrange array such that even positioned are greater than odd133
1004Next Greater Element III LeetCode Solution133
1005Find the Difference Leetcode Solution133
1006First missing positive133
1007Maximum Number of Ways to Partition an Array LeetCode Solution133
1008Unique Paths II133
1009Maximum Length of Repeated Subarray133
1010Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space133
1011Binary Search Tree Delete Operation133
1012Sign of the Product of an Array LeetCode Solution133
1013Kill Process LeetCode Solution133
1014Climbing stairs132
1015My Calendar I LeetCode Solution132
1016Longest subsequence such that difference between adjacents is one132
1017Count subarrays where second highest lie before highest132
1018Find the First Circular Tour that visits all the Petrol Pumps132
1019Find number of pairs in an array such that their XOR is 0132
1020Boundary Traversal of binary tree132
1021Number Of Longest Increasing Subsequence132
1022Insertion in a Binary Tree132
1023Graph Valid Tree LeetCode Solution132
1024Balanced Binary Tree132
1025Design Hit Counter LeetCode Solution131
1026Validate Binary Search Tree131
1027Advantages of BST over Hash Table131
1028Largest Number Leetcode Solution131
1029Double the first element and move zero to end131
1030Super Ugly Number131
1031Move all negative elements to end in order with extra space allowed131
1032Construct Binary Tree from given Parent Array representation131
1033Make The String Great Leetcode Solution131
1034Partition Equal Subset Sum131
1035Morris Inorder Traversal131
1036Valid Boomerang Leetcode Solution131
1037Implement Trie (Prefix Tree) Leetcode Solution130
1038Shortest Completing Word Leetcode Solution130
1039Boolean Parenthesization Problem130
1040Recover Binary Search Tree Leetcode Solution130
1041Add two numbers130
1042Ugly Numbers130
1043Compute nCr % p130
1044Bitwise AND of Numbers Range LeetCode Solution129
1045Available Captures for Rook Leetcode Solution129
1046Maximum difference between frequency of two elements such that element having greater frequency is also greater129
1047Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’129
1048String Matching in an Array Leetcode Solution129
1049Minimum Index Sum of Two Lists129
1050Generate Parentheses Leetcode Solution129
1051Employee Importance LeetCode Solution129
1052Kth Smallest Element in a Sorted Matrix LeetCode Solution129
1053Binary Search Tree129
1054Count minimum steps to get the given desired array129
1055Minimum Size Subarray Sum129
1056Ugly Number II LeetCode Solution129
1057Scramble String LeetCode Solution128
1058Defanging an IP Address LeetCode Solution128
1059Construction of Longest Increasing Subsequence (N log N)128
1060Populating Next Right Pointers in Each Node Leetcode Solution128
1061Find Peak Element128
1062Maximum length subsequence with difference between adjacent elements as either 0 or 1128
1063Invalid Transactions LeetCode Solution128
1064Maximum Sum of 3 Non-Overlapping Subarrays128
1065Binary Tree Right Side View LeetCode Solution128
1066Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution128
1067Combination Sum IV LeetCode Solution128
1068Find whether a subarray is in form of a mountain or not128
1069Longest Bitonic Subsequence128
1070Maximize Distance to Closest Person LeetCode Solution128
1071Number of palindromic paths in a matrix128
1072Regular Expression Matching Regular Expression Matching LeetCode Solution127
1073Iterative Depth First Traversal of Graph127
1074Maximum weight transformation of a given string127
1075Remove Palindromic Subsequences Leetcode Solution127
1076Search in Sorted Rotated Array127
1077Increasing Triplet Subsequence LeetCode Solution127
1078Number of Students Doing Homework at a Given Time Leetcode Solution127
1079Clone a Binary Tree with Random Pointers127
1080Find a Peak Element II LeetCode Solution127
1081Constant time range add operation on an array127
1082Lowest Common Ancestor126
1083Remove Duplicates from Sorted Array II Leetcode Solution126
1084Day of the Year Leetcode Solution126
1085Find the minimum distance between two numbers126
1086Smallest Common Region Leetcode Solution126
1087Number of Closed Islands Leetcode Solution126
1088Count pairs from two sorted arrays whose sum is equal to a given value x126
1089Custom Sort String Leetcode Solution126
1090Divisible Pairs Counting126
1091Path Sum II LeetCode Solution126
1092Types of Binary Tree125
1093Number of siblings of a given Node in n-ary Tree125
1094Path Sum125
1095Largest BST Subtree LeetCode Solution125
1096Find maximum difference between nearest left and right smaller elements125
1097Print Next Greater Number of Q queries125
1098Next Permutation Leetcode Solution125
1099Distinct Subsequences125
1100Print all triplets in sorted array that form AP125
1101Rearrange array such that even index elements are smaller and odd index elements are greater125
1102Binary Tree Data Structure125
1103Kth Smallest Product of Two Sorted Arrays LeetCode Solution125
1104Serialize and Deserialize Binary Tree LeetCode Solution125
1105Write Code to Determine if Two Trees are Identical124
1106Root to Leaf path with target sum Leetcode Solutions124
1107Minimum Absolute Difference in BST Leetcode Solution124
1108Bottom View of a Binary Tree124
1109Find Smallest Range Containing Elements from k Lists124
1110Subarrays with K Different Integers Leetcode Solution124
1111Consecutive Characters LeetCode Solution124
1112Level of Each node in a Tree from source node124
1113Find Three Element From Different Three Arrays Such That a + b + c = sum124
1114Third Maximum Number Leetcode Solution123
1115Print Right View of a Binary Tree123
1116Longest Subarray of 1’s After Deleting One Element LeetCode Solution123
1117Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution123
1118Remove duplicates from sorted array123
1119Cells with Odd Values in a Matrix LeetCode Solution123
1120Subset Sum Problem in O(sum) space123
1121Topological Sorting123
1122Products of ranges in an array123
1123Cutting a Rod123
1124Reformat The String Leetcode Solution122
1125Queries for Number of Distinct Elements in a Subarray122
1126Palindrome Permutation LeetCode Solution122
1127Closest Binary Search Tree Value Leetcode Solution122
1128Maximum Product Subarray122
1129Maximum Binary Tree122
1130Convert BST into a Min-Heap without using array122
1131K maximum sums of overlapping contiguous sub-arrays122
1132Count Largest Group Leetcode Solution121
1133Iterative method to find ancestors of a given binary tree121
1134Valid Tic-Tac-Toe State LeetCode Solution121
1135Search an Element in Sorted Rotated Array121
1136Minimum Score Triangulation of Polygon Leetcode Solution121
1137Mean of Array After Removing Some Elements Leetcode Solution121
1138Diameter of N-Ary Tree LeetCode Solution121
1139Print modified array after executing the commands of addition and subtraction121
1140Construct K Palindrome Strings LeetCode Solution120
1141Prime Palindrome LeetCode Solution120
1142Find a sorted subsequence of size 3 in linear time120
1143Golomb sequence120
1144Moser-de Bruijn Sequence120
1145Sum of Even Numbers After Queries120
1146Thousand Separator Leetcode Solution120
1147Kth Smallest Number in Multiplication Table Leetcode Solution120
1148Minimum sum of squares of character counts in a given string after removing k characters120
1149Search Insert Position120
1150Factorial Trailing Zeroes LeetCode Solution119
1151Find maximum length Snake sequence119
1152Red-Black Tree Introduction119
1153Longest Increasing Consecutive Subsequence119
1154Merge two BSTs with limited extra space119
1155Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution119
1156Maximum Product of Splitted Binary Tree LeetCode Solution118
1157Possible Bipartition LeetCode Solution118
1158Compare Strings by Frequency of the Smallest Character Leetcode Solution118
1159Transform a BST to Greater sum Tree118
1160Swapping Nodes in a Linked List Leetcode Solution118
1161Delete Nodes and Return Forest Leetcode Solution118
1162Palindromic Substrings Leetcode Solution118
1163Binary Tree to Binary Search Tree Conversion118
1164Decrease Elements To Make Array Zigzag LeetCode Solution118
1165Find the smallest binary digit multiple of given number118
1166Bus Routes Leetcode Solution118
1167Minimum Sideway Jumps LeetCode Solution118
1168Maximize sum of consecutive differences in a circular array117
1169Check Array Formation Through Concatenation Leetcode Solution117
1170Priority Queue117
1171Swap Nodes In Pairs117
1172Number of Orders in the Backlog Leetcode Solution117
1173Count Pairs Whose Products Exist in Array117
1174Longest Repeated Subsequence117
1175Decision Tree117
1176Minimum Cost to Move Chips to The Same Position LeetCode Solution117
1177Count even length binary sequences with same sum of first and second half bits117
1178Rotate Array117
1179Matchsticks to Square Leetcode Solution117
1180K’th Largest element in BST using constant extra space117
1181Find Largest Value in Each Tree Row LeetCode Solution116
1182Minimum Moves to Equal Array Elements LeetCode Solution116
1183Web Crawler LeetCode Solution116
1184Given a binary tree, how do you remove all the half nodes?115
1185Contiguous Array LeetCode Solution115
1186Maximum sum bitonic subarray115
1187Closest Leaf in a Binary Tree LeetCode Solution115
1188Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution115
1189First Bad Version115
1190Search Suggestions System LeetCode Solution115
1191Array Queries for multiply replacements and product114
1192Moving Stones Until Consecutive Leetcode Solution114
1193Divide Two Integers Leetcode Solution114
1194Queue Reconstruction by Height114
1195Integer Break LeetCode Solution114
1196Reformat Date LeetCode Solution113
1197Kth Smallest Element in a BST113
1198Reverse a Path in BST using Queue113
1199How to print maximum number of A’s using given four keys113
1200Convert Sorted Array to Binary Search Tree LeetCode Solutions113
1201Maximum number of segments of lengths a, b and c113
1202Maximum Depth Of Binary Tree113
1203Maximum sum of pairs with specific difference113
1204Sum of Left Leaves LeetCode Solution113
1205Lowest Common Ancestor in Binary Search Tree113
1206Valid Triangle Number113
1207Champagne Tower LeetCode Solution113
1208Write a function to get the intersection point of two Linked Lists112
1209Longest Common Prefix Using Word by Word Matching112
1210Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution112
1211Replace two consecutive equal values with one greater112
1212Range Sum Query using Sparse Table112
1213Lowest Common Ancestor of a Binary Tree Leetcode Solution112
1214Guess The Word112
1215Range Queries for Longest Correct Bracket Subsequence111
1216Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution111
1217Maximize Elements Using Another Array111
1218New 21 Game111
1219LRU Cache Leetcode Solution111
1220Graph and its representation111
1221Flatten 2D Vector LeetCode Solution111
1222Print modified array after multiple array range increment operations111
1223Check Completeness of a Binary Tree LeetCode Solution111
1224Print n terms of Newman-Conway Sequence111
1225Symmetric Tree LeetCode Solution Leetcode Solution111
1226Path Crossing Leetcode Solution110
1227Queries on Probability of Even or Odd Number in given Ranges110
1228Maximum Value at a Given Index in a Bounded Array LeetCode Solution110
1229Valid Perfect Square LeetCode Solution110
1230Concatenation of Array LeetCode Solution110
1231Design Skiplist LeetCode Solution110
1232Largest Plus Sign Leetcode Solution110
1233Check if each internal node of a BST has exactly one child110
1234Arithmetic Slices II – Subsequence LeetCode Solution110
1235Missing Number109
1236Sliding Window Median Leetcode Solution109
1237Graph Cloning109
1238The kth Factor of n Leetcode Solution109
1239Check if all levels of two Binary Tree are anagrams or not109
1240Find Minimum in Rotated Sorted Array II LeetCode Solution109
1241BST to a Tree with Sum of all Smaller Keys109
1242Maximum Array from Two given Arrays Keeping Order Same109
1243Maximum sum of a path in a Right Number Triangle109
1244Merge Sort109
1245Minimum Swaps To Make Sequences Increasing LeetCode Solution109
1246Perfect Squares LeetCode Solution109
1247Check for Identical BSTs without building the trees109
1248Smallest Range II Leetcode Solution108
1249Mean of range in array108
1250Count Subsets Having Distinct Even Numbers108
1251Bold Words in String LeetCode Solution108
1252Parallel Courses II LeetCode Solution108
1253Power of Two108
1254Count and Toggle Queries on a Binary Array108
1255Min Cost Climbing Stairs LeetCode Solution107
1256Image Overlap LeetCode Solution107
1257Find minimum number of merge operations to make an array palindrome107
1258Contiguous Array107
1259Maximum Product Subarray107
1260Check If a String Can Break Another String Leetcode Solution106
1261Minimum Remove to Make Valid Parentheses LeetCode Solution106
1262Excel Sheet Column Title LeetCode Solution106
1263Next greater element105
1264Verify Preorder Serialization of a Binary Tree105
1265Find k-th smallest element in BST (Order Statistics in BST)105
1266Number of elements less than or equal to a given number in a given subarray104
1267Palindrome Partitioning104
1268Print Ancestors of a Given Binary Tree Node Without Recursion104
1269Merge k Sorted Lists Leetcode Solution104
1270Peeking Iterator LeetCode Solution104
1271Minimum Time to Collect All Apples in a Tree LeetCode Solution103
1272Orderly Queue LeetCode Solution103
1273Merge Sorted Array102
1274Check if two nodes are on the same path in a Tree102
1275Check in binary array the number represented by a subarray is odd or even102
1276Newman–Shanks–Williams prime102
1277Different Ways to Add Parentheses Leetcode Solution100
1278Koko Eating Bananas LeetCode Solution100
1279Check if X can give change to every person in the Queue99
1280Largest Submatrix With Rearrangements LeetCode Solution98
1281Find maximum average subarray of k length98
1282Longest Substring Without Repeating Characters Leetcode Solution98
1283Maximum Sum Increasing Subsequence98
1284Arranging Coins Leetcode Solution98
1285Minimum Total Space Wasted With K Resizing Operations LeetCode Solution97
1286Range Minimum Query (Square Root Decomposition and Sparse Table)97
1287Minimum Number of People to Teach LeetCode Solution96
1288Number of indexes with equal elements in given range96
1289Queries for Decimal Values of Subarrays of a Binary Array96
1290Array Nesting Leetcode Solution96
1291Maximum product of an increasing subsequence95
1292Convert to Base -2 LeetCode Solution94
1293Check given array of size n can represent BST of n levels or not94
1294Binary Tree to Binary Search Tree Conversion using STL set94
1295Jump Game IV LeetCode Solution93
1296Find the Winner of the Circular Game LeetCode Solution93
1297Convert a BST to a Binary Tree such that sum of all greater keys is added to every key93
1298Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution93
1299Random Pick Index LeetCode Solution93
1300Queries on XOR of greatest odd divisor of the range92
1301Add Two Numbers II Leetcode Solution92
1302Encoded String With Shortest Length LeetCode Solution92
1303Reach a Number LeetCode Solution92
1304Continuous Subarray Sum LeetCode Solution91
1305Insert Delete GetRandom O(1) Leetcode Solution90
1306Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution90
1307Vertical Order Traversal of Binary Tree LeetCode Solution89
1308Palindrome Number LeetCode Solution89
1309Design Underground System Leetcode Solution88
1310Print Maximum Length Chain of Pairs86
1311Detect Capital Leetcode Solution83
1312Design A Leaderboard Leetcode Solution83
1313Substring with Concatenation of All Words Leetcode Solution80
1314Top K Frequent Elements LeetCode Solution79
1315Minimum Swaps to Group All 1’s Together Leetcode Solution78
1316Count Sub Islands LeetCode Solution76
1317Minimum Path Sum Leetcode Solution75
1318Decode String Leetcode Solution74
1319Odd Even Linked List Leetcode Solution73
1320Binary Tree Inorder Traversal LeetCode Solution72
1321Shifting Letters LeetCode Solution72
1322Longest Common Subsequence LeetCode Solution72
1323Best Meeting Point LeetCode Solution71
1324Shortest Unsorted Continuous Subarray LeetCode Solution71
1325Maximum Population Year LeetCode Solution71
1326Find the Town Judge LeetCode Solution70
1327Find the Town Judge LeetCode Solution70
1328Sum Root to Leaf Numbers LeetCode Solution70
1329Design Add and Search Words Data Structure LeetCode Solution68
1330Maximum Population Year LeetCode Solution66
1331Rectangle Overlap LeetCode Solution66
1332Score of Parenthesis LeetCode Solution65
1333Flatten Binary Tree to Linked List LeetCode Solution63
1334Insert into a Sorted Circular Linked List LeetCode Solution63
1335Stone Game IV LeetCode Solution62
1336Is Graph Bipartite? LeetCode Solution60
1337Range Sum Query 2D – Immutable LeetCode Solution60
1338Valid Triangle Number LeetCode Solution59
1339Reveal Cards In Increasing Order Leetcode Solution59
1340Divide Chocolate LeetCode Solution51
1341Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution46
1342Range Sum of BST LeetCode Solution44
1343Reverse Integer Leetcode Solution41
1344Sort Colors LeetCode Solution40
1345Find K Closest Elements LeetCode Solution38
1346Excel Sheet Column Number LeetCode Solution34
1347Rotate String LeetCode Solution34
1348Maximum Side Length of a Square with Sum Less than or Equal to Threshold LeetCode Solution33
1349High Five LeetCode Solution6
1350H-Index Leetcode Solution2
Translate »