Binary Tree Inorder Traversal LeetCode Solution

Difficulty Level Easy
Frequently asked in Adobe Amazon Apple Bloomberg Facebook Goldman Sachs Google Microsoft Oracle Yahoo
Binary Tree Depth First Search Stack TreeViews 74

Problem Statement:

Binary Tree Inorder Traversal LeetCode solution

Given the root of a binary tree, return the inorder traversal of its nodes’ values.

Example 1:

Binary Tree Inorder Traversal LeetCode SolutionPin

Input:

 root = [1,null,2,3]

Output:

 [1,3,2]

Example 2:

Input:

 root = []

Output:

 []

Example 3:

Input:

 root = [1]

Output:

 [1]

Constraints:

  • The number of nodes in the tree is in the range [0, 100].
  • -100 <= Node.val <= 100

Approach:

1. We will do recursion to find the binary tree inorder traversal. of a tree.

2. In order traversal means first to traverse the left subtree, then the root of the tree, at last, the right subtree (left->root->right).

3. The Base condition of our recursion will be when we reach the leaf node i.e. root will be null.

4. Finally, we’ll be left with binary tree inorder traversal.

Code:

Binary Tree Inorder Traversal C++ solution:

class Solution {
public:
    #define ll int
   
    void rec(TreeNode *root,vector<ll>&v)
    {
        if(root==NULL)
            return;
        rec(root->left,v);
        v.push_back(root->val);
        rec(root->right,v);
    }
    vector<int> inorderTraversal(TreeNode* root) {
         vector<ll>v;
        rec(root,v);
        return v;
    }
};

Binary Tree Inorder Traversal Java solution:

class Solution {
    void rec(TreeNode root,List<Integer> ans)
    {
        if(root==null)
            return;
        rec(root.left,ans);
        ans.add(root.val);
        rec(root.right,ans);
    }
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer>ans= new ArrayList<>();
        rec(root,ans);
        return ans;
    }
}

Complexity analysis of Binary Tree Inorder Traversal LeetCode solution:

Time Complexity:

Time complexity will be o(n). We are traveling every node only once.

Space Complexity:

Space complexity will be o(n). We are storing the value of every node for our traversal that’s why we are taking space of o(n).

 

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