Reverse Nodes in k-Group LeetCode Solution

Frequently asked in Adobe Amazon Apple Bloomberg ByteDance Capital One eBay Intuit MakeMyTrip Microsoft Oracle Snapchat Tencent Uber VMware Yahoo Zenefits
Walmart ZoomViews 19

Problem Statement:

Reverse Nodes in k-Group LeetCode Solution – Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list.

k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes, in the end, should remain as it is.

You may not alter the values in the list’s nodes, only nodes themselves may be changed.


Example 1:

Reverse Nodes in k-Group LeetCode SolutionPinInput:

 head = [1,2,3,4,5], k = 2



Example 2:


 head = [1,2,3,4,5], k = 3




  • The number of nodes in the list is n.
  • 1 <= k <= n <= 5000
  • 0 <= Node.val <= 1000

Follow-up: Can you solve the problem in O(1) extra memory space?



  • In order to Reverse Nodes in k-Group LeetCode Solution. First, we will focus on how to reverse node in the k group so at first, we will count the total length of the linked list.
  • Then we will reverse the linked list according to the given size ‘k’ and reverse the linked list.
  • After that, we will decrease the total length by k and will check if the length of the linked list is greater than or equal to the size then we will repeat the previous steps by using recursion.
  • Else we will link the linked list with the remaining node.
  • Hence we will reverse the linked list in the k-group.


  • First, we will make a variable total(length of linked list). after that will count the total length by using the while loop.
  • Then we will reverse the given linked list according to size – next – (next of current element), prev – ( previous element of current), and current.
  • Then we will decrease the total length by k after reversing the linked list and will check if the total length will be greater or equal to k then we will do the previous steps by using recursion.
  • Else will link to the remaining node of the linked list.
  • At last, we will return to the prev.

Image –

Reverse Nodes in k-Group LeetCode SolutionPin Reverse Nodes in k-Group LeetCode SolutionPin Reverse Nodes in k-Group LeetCode SolutionPin

class Solution:
    def reverseKGroup(self, head: Optional[ListNode], k: int) -> Optional[ListNode]:
        total = 0
        current = head
            total += 1
            current =
        prev = None
        current = head
        count = 0
        while(current and count < k ):
            next =
   = prev
            prev = current
            current = next
            count += 1
        total -= k
        if total >= k:
   = self.reverseKGroup(next,k)
   = next
        return prev
class Solution {
    public ListNode reverseKGroup(ListNode head, int k) {
        int total = 0;
        ListNode current = head;
        while(current != null){
            current =;
        int count = 0;
        ListNode prev = null;
        ListNode c = head;
        ListNode next = null;
        while(c != null && count < k){
            next =;
   = prev;
            prev = c;
            c = next;
        total -= k;
        if(total >= k){
   = reverseKGroup(next,k);
   = next;
        return prev;

Complexity Analysis for Reverse Nodes in k-Group LeetCode Solution

Time Complexity: O(N), As we have traversed the LinkedList three times.

Space Complexity: O(1), As we haven’t taken any extra space.





Top Interview Questions

S.No Interview Question Number of times has been asked
1Delete a node in doubly linked list2887
2Java program to find the number of Nodes in a Binary Tree2541
3Reverse a string without affecting special characters2524
4Palindrome using Recursion2488
5Delete a node of a linked list at given position2022
6Quick Sort1768
7Insert nodes in a linked list in a sorted way (Ascending Order)1709
8Find elements pair from array whose sum equal to number1687
9Sort Elements by Frequency of Occurrences1672
10Write a program to print all permutations of a given string1655
11Find Minimum Distance Between Two Numbers in an Array1517
12Create a Doubly Linked List1484
13Reverse an Array1464
14Smallest window in a string containing all characters of another string1436
15Recursively remove all adjacent duplicates1405
16Find a Triplet That Sum to a Given Value1391
17First Repeating Element1384
18Sum of numbers in String1361
19Arrange Even and Odd number such that Odd comes after Even1357
20Smallest Positive Number Missing in an Unsorted Array1326
21Check if the Elements of an Array are Consecutive1291
22Detect a loop in the Linked List1272
23Largest Sum Contiguous Subarray1261
24Quick Sort on SIngly Linked List1257
25Print all Possible Combinations of R Elements in a given Array of size N1247
26Subarray with Given Sum1247
27Recursive function to do substring search1245
28Find the Maximum Repeating Number in Array1203
29Binary Tree Level order traversal in Java1155
30Find the First and Second Smallest Elements1155
31Maximum Subarray Sum using Divide and Conquer1141
32Check if two linked lists are identical1141
33Remove characters from first string which are in second1114
34Find Leaders in an Array1092
35Swap nodes in the linked list1083
36Find the second most frequent character1034
37Find the Number Occurring Odd Number of Times in an Array1033
38Arrange given Numbers to Form the Biggest Number II1027
39Given a string find its first non-repeating character1014
40Find Triplet in Array With a Given Sum1002
41Given a sorted array and a number x, find the pair in array whose sum is closest to x994
42Total number of occurrences of a given item in the linked list991
43A Program to check if strings are rotations of each other or not987
44Print all possible words from phone digits972
45Find the Missing Number962
46Rearrange Positive and Negative Numbers Alternatively in Array950
47Longest Palindromic Substring944
48Segregate even and odd nodes in a linked list933
49Print Longest common subsequence924
50Transform one string to another using minimum number of given operations912
51Union and Intersection of Two Linked Lists905
52Check rearranged string can form a palindrome895
53Rearrange given Array in Maximum Minimum Form876
54Iterative Implementation of Quick Sort868
55Insertion Sort858
56Count Possible Triangles855
57Multiplication of Two Matrices840
58Count of Triplets With Sum Less than Given Value829
59Stock Buy Sell to Maximize Profit827
60Check if the linked list is palindrome826
61Rotate a Linked List825
62Concatenation of two strings804
63Tug of War798
64Print all duplicates in the input string796
65Count Number of Substrings with K Distinct Character’s794
66Find Nearest Greater and Smaller Element782
67Reverse String Without Temporary Variable776
68The Celebrity Problem771
69Remove ‘b’ and ‘ac’ from a given string769
70Find Pythagorean Triplets from Array768
71Find all Common Elements in Given Three Sorted Arrays763
72Remove all duplicates in an unsorted linked list740
73Find the Row with Maximum Number of 1’s737
74Find the subarray whose sum is equal to a given number X736
75Remove Minimum Characters so that Two Strings Become Anagrams735
76Find the Peak Element from an Array734
77Addition of Two Matrices729
78Find Smallest Missing Number in a Sorted Array725
79Generate all Binary Strings Without Consecutive 1’s723
80A Product Array Puzzle720
81Maximum Sum of Non Consecutive Elements710
82Implement Two Stacks in an Array706
83Lexicographic rank of string697
84Check if Two given Matrices are Identical689
85Maximum Product Subarray II686
86Multiplication of Previous and Next681
87Subtraction of Two Matrices673
88Merge K Sorted Arrays and Print Sorted Output668
89Divide a string in N equal parts665
90Move All the Zeros to the End of the Given Array665
91Form Minimum Number from Given Sequence of D’s and I’s664
92Online Algorithm for Checking Palindrome in a Stream663
93Check whether two strings are anagram of each other656
94Remove recurring digits in a given number655
95Sort a stack using a temporary stack651
96Maximum Circular Subarray Sum649
97Sort a linked list that is sorted alternating ascending and descending645
98Subarray and Subsequence638
99Find the Minimum Element in a Sorted and Rotated Array636
100Move last element of the Linked List at first place632
101First Circular Tour to Visit all the Petrol Bunks632
102Compare two strings(linked lists)628
1033Sum Leetcode Solution627
104Maximum Element in an Array which is Increasing and then Decreasing626
105Largest Subarray with Equal Number of 0’s and 1’s626
106Palindrome Permutations of a String625
107Flattening a linked list623
108Palindromes in a given range621
109Majority Element618
110Minimum insertions to form a shortest palindrome617
111Pangram Checking616
112Run length encoding615
113Print all permutations with repetition613
114Elements Appear more than N/K times in Array611
115Minimum Characters to be Added at Front to Make String Palindrome608
116Most repeating character in a string605
117Two Sum Leetcode Solution601
118Rotate string to get lexicographically minimum string600
119Repeated Subsequence of Length Two or More597
120Merge a linked list into another at alternate positions596
121Remove all duplicates in a sorted linked list594
122Rearrange a given linked list in-place594
123Minimum number of Merge Operations to make an Array Palindrome593
124Print all anagrams together in a sequence of words589
125Reorder an Array According to the Given Indexes580
126Pancake Sorting Problem578
127Merge Overlapping Intervals II567
128Clone a Linked List with next and random pointer565
129Transpose of a Matrix565
130Remove duplicates from a string565
131Longest Palindrome can be Formed by Removing or Rearranging Characters564
132Smallest Palindrome after Replacement564
133Remove Extra Spaces from a String563
134Maximum Sum Increasing Subsequence559
135Removing Spaces from a String using stringstream559
136Size of The Subarray With Maximum Sum558
137Check if a given string is a rotation of a palindrome558
138Partition Problem551
139Check whether Strings are K Distance Apart or Not545
140Generate all Binary Strings from Given Pattern545
141Length of Longest valid Substring541
142Delete Last Occurrence538
143Check if Two given Strings are Isomorphic to each other536
144Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized534
145Insert Node in the Sorted Linked List532
146Program to Toggle all Characters in a String526
147Maximum difference between two elements such as larger element comes after smaller525
148Given string is interleaving of two other strings or not525
149Count Minimum Steps to Get the given Array514
150Check length of a String is Equal to the Number Appended at its Last513
151Number of Smaller Elements on Right Side512
152Check if all Rows of a Matrix are Circular Rotations of Each Other507
153Find Pair with Given Difference506
154Longest Common Prefix using Divide and Conquer506
155Merge sort better than quick sort for linked lists505
156Compare Two Version Numbers501
157Find nth node of the Linked list from the end497
158Print all interleavings of given two strings496
159Print Reverse of a string (Recursion)495
160Median of Two Sorted Arrays LeetCode Solution494
161Find a Fixed Point in a Given Array494
162Sort 0s 1s and 2s in an Array493
163Reorder Array Using Given Indexes492
164Reverse words in a given string490
165Merge two sorted linked lists such that merged list is in reverse order484
166Find the Subarray of given length with Least Average484
167Split linked list using alternate nodes481
168Print all Palindromic Partitions of a String475
169Print string of odd length in ‘X’ format470
170Find Element Using Binary Search in Sorted Array468
171Find K Length Subarray of Maximum Average465
172Swap Kth Node from beginning with Kth Node from End461
173Find Duplicates in an Array in Most Efficient Way459
174print all palindromic partitions454
175Shortest Superstring Problem454
176Check if String Follows Order of Characters by a Pattern or not450
177Maximum Length of Chain Pairs448
178Sort a String According to Another String446
179Flatten a multilevel linked list445
180Sorting a K Sorted Array439
181Program to add two binary digits431
182Recursively print all the sentences that can be formed from list of word lists427
183Longest Span with same Sum in two Binary Arrays II426
184Find a Sorted Subsequence of size 3426
185Longest Common Prefix Using Binary Search II425
186Reverse a Linked List in groups425
187Caesar Cipher425
188Find the two Numbers with Odd Occurrences in an Unsorted Array423
189Kth Non-repeating Character421
190Reverse a Singly Linked List (Iterative/Non-Recursive)420
191Check if String can Become Empty by Recursively Deleting given Substring416
192Rearrange a linked list in Zig-Zag410
193Longest Common Prefix Word by Word Matching409
194Permutations of a Given String Using STL406
195Rotate Image by 90 degrees406
196Perfect Reversible String404
197Pancake Sorting402
198Merging Two Sorted Arrays401
199Find First non-repeating character in a string400
2001`s and 2`s complement of binary number398
201Increasing Subsequence of Length three with Maximum Product394
202Maximum occurring character in a string393
203Find the point where a monotonically increasing function becomes positive first time392
204List items containing all characters of a given word392
205Four Elements that Sum to Given390
206Sort a linked list with 0s, 1s and 2s389
207Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes387
208Longest Common Prefix using Character by Character Matching385
209Count Number of Occurrences in a Sorted Array383
210Palindrome string (number)382
211Valid Parentheses LeetCode Solution380
212Delete N nodes after M379
213Minimum Characters to be Removed to Make a Binary String Alternate377
214Even Substring Count375
215Split a string374
216Sorting the array of strings371
217Recursive Implementation of atoi()371
218Convert a String that is Repetition of a Substring of Length K369
219Check if a Linked list of Strings form a Palindrome367
220Print Shortest Path to Print a String on Screen364
221Maximum Subarray Leetcode Solution361
222Print All Distinct Elements of the Array359
223Convert string1 to string2 in one edit359
224Reverse a String using Stack359
225Count the number of words358
226Matrix Chain Multiplication using Dynamic Programming358
227Find the first Repeating Number in a Given Array358
228Nth Character in Concatenated Decimal String358
229Reverse a singly linked list recursively356
230wildcard character matching355
231Lower Case To Upper Case352
232Can we reverse a linked list in less than O(n) time ?350
233Binary Tree to Doubly linked list349
234Sort Elements by Frequency II345
235Longest Common Subsequence with Permutations343
236Find the Lost Element From a Duplicated Array343
237Merge Two Sorted Arrays341
238Split Four Distinct Strings340
239Find middle of the Linked List337
240Count the Pairs at Same Distance as in English Alphabets334
241Roman to Integer Leetcode Solution334
242Toeplitz Matrix328
243Palindrome Permutation326
244Next Greater Element in an Array325
245Word Search Leetcode Solution325
246Move all negative elements to one side of array322
247N queen problem322
248Searching a node in a Binary Search Tree317
249Find All Pairs With a Given Difference317
250Find Nth Node315
251Sudoku Solver315
252Reverse Bits314
253First non Repeating Element314
254String(represents an integer) to value313
255Print all Possible Ways to Break a String in Bracket Form313
256Number of Islands LeetCode Solution313
257Count Pairs With Given Sum313
258Delete a Tree311
259Reverse a String311
260Change Gender of a given String311
261Types of Binary Tree311
262Triplet from three linked lists with given sum311
263Repeated Substring Pattern309
264How to Efficiently Implement k Stacks in a Single Array?308
265Meeting Rooms II LeetCode Solution308
266Reverse a linked list307
267Fibonacci numbers307
268Sort an array of strings306
269Delete a node under given conditions306
270Number of sub-strings which recursively add up to 9305
271Longest Palindromic Substring LeetCode Solution304
272Min Stack304
273Most Frequent Element in an Array304
274Cuckoo sequence program302
275Longest Common Extension300
276Dijkstra Algorithm300
277Binary Tree298
278Remove spaces from a string296
279House Robber Leetcode Solution296
280Max stack295
281Best Time to Buy and Sell Stock  II Leetcode Solution293
282Subset Leetcode292
283Word Search290
284Shuffle a given Array289
285Remove middle points in a linked list of line segments288
286KMP Algorithm288
287Plus One Leetcode Solution287
288Minimize the maximum difference between the heights286
289Expression Evaluation286
290Find, second, frequent, character286
291Combination Sum Leetcode Solution285
292Search Insert Position Leetcode Solution284
293Number Of 1 bits282
294Reverse words in a string282
295Evaluation of Postfix Expression280
296Pair of Positive Negative Values in an Array280
297Set Matrix Zeroes279
298Sliding Window Technique279
299Min Stack Leetcode Solution276
300Rabin Karp Algorithm276
301Valid Palindrome Leetcode Solution276
302Subarray with 0 sum275
303Sort linked which is sorted on absolute values273
304Common elements in all rows of a given matrix273
305Backspace String Compare273
306Clone a linked list with next and random pointer (Hashing)271
307Merge Sorted Arrays Leetcode Solution270
308Delete middle element of a stack269
309Sqrt(x) Leetcode Solution269
310Reversing a Queue268
311Implementation of Deque using Doubly Linked List266
312Contains Duplicate II Leetcode Solution265
313Count of index pairs with equal elements in an array264
314Tower Of Hanoi263
315Contains Duplicate263
316Find Top K (or Most Frequent) Numbers in a Stream263
317Product of array except self263
318Combination Sum262
319String Compression262
320Reverse individual words262
321Pascal Triangle Leetcode262
322Count subarrays with equal number of 1’s and 0’s262
323Intersection of Two Arrays II Leetcode Solution261
324How to Delete a Linked List261
325Minimum swaps required to bring all elements less than or equal to k together260
326Count Odd Numbers in an Interval Range Leetcode Solution260
327Page Replacement Algorithms in Operating Systems260
328Integer to Roman Leetcode Solution259
329Group Words With Same Set of Characters258
330Segregate even and odd numbers258
331Single Number Leetcode Solution257
332Bellman Ford Algorithm257
333Second Most Repeated Word in a Sequence257
334Find sum of non-repeating elements (distinct) elements in an array256
335Postfix to Infix Conversion256
336Sorting array using Stacks256
337Sum of minimum and maximum elements of all subarrays of size k256
338Minimum Value to Get Positive Step by Step Sum Leetcode Solution255
339Add Binary Leetcode Solution255
340Arithmetic Expression Evaluation255
341Smallest Subarray with k Distinct Numbers255
342Sort elements by frequency255
343K-th Smallest Element in a Sorted Matrix254
344Next Permutation253
345Minimum operation to make all elements equal in array252
346Top K Frequent Words252
347Construct Binary Tree from Given Inorder and Preorder Traversals252
348Count subarrays having total distinct elements same as original array251
349Maximum Number of Balloons Leetcode Solution251
350Pow(x, n) Leetcode Solution251
351Palindrome Linked List Leetcode Solution250
352Given two unsorted arrays find all pairs whose sum is x250
353Convex Hull Algorithm249
354Design a stack that supports getMin() in O(1) time and O(1) extra space249
355Longest Common Prefix Leetcode Solution249
356Scramble String249
357Special Number248
358Longest Substring Without Repeating Characters LeetCode Solution248
359First element occurring k times in an array248
360Majority Element Leetcode Solution247
361Find duplicates in a given array when elements are not limited to a range247
362Kruskal Algorithm247
363Permutations Leetcode Solution247
364Find Lucky Integer in an Array Leetcode Solution246
365Evaluate Division246
366Third Maximum Number Leetcode Solution245
367Spiral Matrix LeetCode Solution243
368Reversing the First K elements of a Queue243
369Maximum possible difference of two subsets of an array243
370Check if two arrays are equal or not243
371Prefix to Infix Conversion242
372Running Sum of 1d Array Leetcode Solution242
373Reverse a Number Using Stack242
374Number of Good Pairs Leetcode Solution242
375Minimum Path Sum241
376Huffman Coding241
377Fizz Buzz Leetcode241
378Maximum Subarray241
379Find Numbers with Even Number of Digits Leetcode Solution241
380Find the Town Judge Leetcode Solution240
381Maximal Square240
382Unique Paths240
383Minimum Steps to reach target by a Knight239
384Count Primes Leetcode Solutions239
385Group Anagrams239
386Swap Nodes in Pairs Leetcode Solutions239
387Maximum Distance Between two Occurrences of Same Element in Array238
388Single Number238
389Find the Closest Palindrome number238
390Minimum Absolute Difference Leetcode Solution238
391Find the first repeating element in an array of integers237
392Sort Array by Increasing Frequency Leetcode Solution237
393Find top three repeated in array237
394Range Sum Query 2D – Immutable Leetcode Solution237
395Find Number of Employees Under every Employee236
396Pascal’s Triangle II Leetcode Solution236
397Palindrome Substring Queries236
398Cumulative Frequency of Count of Each Element in an Unsorted Array236
399Smallest Element Repeated Exactly K Times236
400Zigzag Conversion236
401Remove Minimum Number of Elements Such That no Common Element Exist in both Array235
402Sorting using trivial hash function235
403Implement Stack and Queue using Deque235
404Power of Two Leetcode Solution235
405Find All Numbers Disappeared in an Array Leetcode Solution235
406Convert String To Int235
407Leetcode Permutations234
408Count Substrings with equal number of 0s, 1s and 2s234
409Sort Integers by The Number of 1 Bit Leetcode Solution234
410How to Implement Stack Using Priority Queue or Heap?233
411Missing Number Leetcode Solution233
412Letter Case Permutation233
413Check if Array Contains Contiguous Integers With Duplicates Allowed233
414Merge Two Sorted Lists Leetcode Solutions233
415Print all subarrays with 0 sum233
416Matrix Diagonal Sum Leetcode Solution233
417Length of the largest subarray with contiguous elements232
418Subarray Sum Equals k232
419Expression Contains Redundant Bracket or Not232
420Fizz Buzz232
421House Robber II Leetcode Solution232
422Bipartite Graph232
423Unique Paths Leetcode Solution231
424Difference between highest and least frequencies in an array231
425LRU Cache Implementation231
426Print All Distinct Elements of a Given Integer Array231
427Prim’s Algorithm231
428Subset sum problem231
429Top K Frequent Elements231
430Happy Number Leetcode Solution231
431Count pairs from two linked lists whose sum is equal to a given value230
432Find Median from data Stream230
433Maximum Depth of Binary Tree Leetcode Solution230
434Decode String230
435Sort a stack using recursion230
436Search in Rotated Sorted Array Leetcode Solution229
437Find all pairs (a, b) in an array such that a % b = k229
438Reverse Integer229
439Find Winner on a Tic Tac Toe Game Leetcode Solution229
440Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution229
441Reverse a Stack Using Recursion228
442Coin Change 2 Leetcode Solution228
443Check If N and Its Double Exist Leetcode Solution228
444Max Consecutive Ones Leetcode Solution228
445Subarrays with distinct elements228
446Monotonic Array LeetCode Solution227
447Capacity To Ship Packages Within D Days Leetcode Solution227
448Nth Catalan Number227
449Find the Difference Leetcode Solution227
450Find The Duplicate Number226
451How Many Numbers Are Smaller Than the Current Number Leetcode Solution226
452Find elements which are present in first array and not in second226
453Pair with given product225
454Integer to English words225
455Text Justification LeetCode Solution225
456Sum of Subarray Ranges Leetcode Solution225
457Trapping Rain Water Leetcode Solution225
458Fibonacci Number LeetCode Solution224
459Priority Queue Using Singly Linked List224
460Floyd Warshall Algorithm224
461Count and Say224
462Edit Distance224
463Find distinct elements common to all rows of a matrix224
464Best Time to Buy and Sell Stock III Leetcode Solution224
465Subarray Sum Equals K LeetCode Solution224
466Reverse Vowels of a String Leetcode Solution224
467Target Sum223
468Remove Duplicates from Sorted Array Leetcode Solution223
469Valid Parenthesis String223
470Find Index of Closing Bracket for a Given Opening Bracket in an Expression223
471Subtract the Product and Sum of Digits of an Integer Leetcode Solution223
472Kth largest element in an Array Leetcode Solutions222
473Reverse a String222
474Jump Game Leetcode Solution221
475Longest subarray not having more than K distinct elements221
476The K Weakest Rows in a Matrix Leetcode Solution221
477Find any one of the multiple repeating elements in read only array221
478Longest Common Prefix using Trie221
479Find Minimum In Rotated Sorted Array221
480Generate a String With Characters That Have Odd Counts Leetcode Solution221
481Design Parking System Leetcode Solution221
482Prefix to Postfix Conversion220
483Find four elements that sum to a given value (Hashmap)220
484Check if a given array contains duplicate elements within k distance from each other220
485Word Ladder LeetCode Solution220
486Rearrange a binary string as alternate x and y occurrences220
487MiniMax Algorithm220
488Delete a Node from linked list without head pointer220
489Find Common Characters Leetcode Solution220
490Intersection of Two Arrays219
491Shuffle String Leetcode Solution219
492Flood Fill LeetCode219
493Sorting a Queue without Extra Space219
494Multiply Strings Leetcode Solution218
495Count number of triplets with product equal to given number218
496Top View of Binary Tree218
497Find missing elements of a range218
498The Stock Span Problem218
499Shortest Palindrome217
500Merge Two Sorted Linked Lists217
501Shuffle the Array Leetcode Solution217
502Find subarray with given sum (Handles Negative Numbers)217
503Best Time to Buy and Sell Stock LeetCode Solution217
504Substring With Concatenation Of All Words217
505Degree of an array217
506Balanced Binary Tree Leetcode Solution217
507Iterative Tower of Hanoi217
508Excel Sheet Column Number Leetcode Solution217
509Slowest Key Leetcode Solution216
510Iterative Inorder Traversal of a Binary Tree216
511Number of Steps to Reduce a Number to Zero Leetcode Solution216
512Priority Queue in C++216
513Postfix to Prefix Conversion216
514Longest Common Subsequence216
515Count and Say Leetcode Solution216
516Kids With the Greatest Number of Candies Leetcode Solution216
517Next Greater Element I Leetcode Solution216
518K-th Distinct Element in an Array215
519Concatenation of Array LeetCode Solution215
520Valid Sudoku215
521Reverse Words in a String III LeetCode Solution215
522Peak Index in a Mountain Array215
523Check for Balanced Parentheses in an Expression215
524Implement Stack using Queues215
525Max Area of Island215
526Move Zeroes LeetCode Solution215
527Minimum Knight Moves LeetCode Solution214
529Convert array into Zig-Zag fashion214
530Longest Common Prefix using Sorting214
531Sum of Left Leaves Leetcode Solutions214
532Find the Duplicate Element214
533Find First and Last Position of Element in Sorted Array Leetcode Solution213
534Linked List Cycle II LeetCode Solution213
535Kth Largest Element in a Stream Leetcode Solution213
536Merge Overlapping Intervals213
537Container with Most Water213
538Implement a stack using single queue213
539Jewels and Stones Leetcode Solution212
540Largest Sum Contiguous Subarray212
541Is Subsequence Leetcode Solution212
542Minimum Moves to Equal Array Elements Leetcode Solution212
543Arrange given numbers to form the biggest number212
544Minimum Delete Operations to make all Elements of Array Same212
545Largest Perimeter Triangle Leetcode Solution212
546Find Sum of all unique sub-array sum for a given array212
547Hamming Distance211
548Check if a queue can be sorted into another queue using a stack211
549Gold Mine Problem211
550Group Multiple Occurrence of Array Elements Ordered by first Occurrence211
551Smallest Subarray With all Occurrences of a Most Frequent Element211
552Excel Sheet Column Title Leetcode Solution211
553Isomorphic Strings Leetcode Solution211
554Zigzag Conversion LeetCode Solution211
555Change the Array into Permutation of Numbers From 1 to N210
556Next Greater Frequency Element210
557How to check if two given sets are disjoint?210
558Last Stone Weight210
559Delete Node in a Linked List Leetcode Solution210
560Contiguous Array Leetcode210
561Find N Unique Integers Sum up to Zero Leetcode Solution210
562N-th Tribonacci Number Leetcode Solution209
563Maximum sum rectangle in a 2D matrix209
564Shuffle an Array209
565Koko Eating Bananas Leetcode Solution209
566Minimum Bracket Reversals209
567Convert a normal BST to Balanced BST209
568Best Time to Buy and Sell Stock208
569Length of Last Word Leetcode Solution208
570Mobile Numeric Keypad Problem208
571Minimum Cost to Hire K Workers208
5723Sum Closest LeetCode Solution208
573Distribute Candies to People Leetcode Solution208
574Summary Ranges Leetcode Solution208
575Count the number of nodes at given level in a tree using BFS208
576Number of Provinces Leetcode Solution207
577Implementation of Deque using circular array207
578Minimum number of subsets with distinct elements207
579Valid Anagrams207
580Find if an Expression has Duplicate Parenthesis or Not207
581Maximum Distance in Array207
582Maximum path sum in a triangle206
583Find Words That Can Be Formed by Characters Leetcode Solution206
584Shortest Path in a Grid with Obstacles Elimination LeetCode Solution206
585Trapping Rain Water LeetCode Solution206
586Decode Ways206
587Frog Jump Leetcode Solution206
588Relative Sort Array Leetcode Solution205
589Integer to Roman205
590Longest Increasing Subsequence205
591Remove All Occurrences of a Substring LeetCode Solution205
592Build Array From Permutation Leetcode Solution205
59301 Matrix LeetCode Solution205
594Rotate Image LeetCode Solution205
595First negative integer in every window of size k205
596LRU Cache LeetCode Solution204
597Delete consecutive same words in a sequence204
598Minimum Operations to convert X to Y204
599Iterative Method to find Height of Binary Tree204
600Maximum Number of Occurrences of a Substring Leetcode Solution204
601Maximum difference between first and last indexes of an element in array204
602Combinations Leetcode Solution204
603Minimum number of distinct elements after removing m items203
604Sort Characters By Frequency LeetCode Solution203
605Sieve of Eratosthenes203
606Count all subsequences having product less than K203
607Island Perimeter Leetcode Solution203
608Smallest Good Base203
609Word Pattern203
610Non-overlapping sum of two sets202
611XOR Operation in an Array Leetcode Solution202
612Find minimum difference between any two elements202
613Remove Linked List Elements Leetcode Solution202
614Find the smallest positive integer value that cannot be represented as sum of any subset of a given array202
615Assign Cookies Leetcode Solution202
616Minimum insertions to form a palindrome with permutations allowed201
617Stone Game LeetCode201
618Rotate List Leetcode Solution201
619Insert Interval Leetcode Solution201
620GCD Of Two Numbers201
621Reverse a stack without using extra space in O(n)201
622Bubble sort using two Stacks201
623Convert Sorted Array to Binary Search Tree Leetcode Solution201
624Sum of f(a[i], a[j]) over all pairs in an array of n integers200
625Same Tree LeetCode Solution200
626The Knapsack Problem200
627Tracking current Maximum Element in a Stack200
628Applications of Breadth First Search and Depth First Search200
629Unique Binary Search Trees199
630Defanging an IP Address Leetcode Solution199
631Find the Duplicate Number LeetCode Solution199
632Find Largest d in Array such that a + b + c = d199
633Maximum Number of Chocolates to be Distributed Equally Among k Students199
634Longest Increasing Path in a Matrix LeetCode Solution199
635Permutation in String Leetcode Solution199
636Reorganize String199
637Isomorphic Strings199
638Count Good Nodes in Binary Tree Leetcode Solution199
639How to Create Mergable Stack?198
640First Unique Character in a String LeetCode Solution198
641Optimal Account Balancing LeetCode Solution198
642License Key Formatting Leetcode Solution198
643Distance Between Bus Stops Leetcode Solution198
644Form minimum number from given sequence198
645Convert an array to reduced form198
646K Empty Slots198
647Printing brackets in Matrix Chain Multiplication Problem198
648Letter Combinations of a Phone Number197
649Employee Free Time LeetCode Solution197
650Minimum Depth of Binary Tree Leetcode Solution197
651Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions196
652Sort Array By Parity LeetCode Solution196
653Convert a Number to Hexadecimal Leetcode Solution196
654Replace Elements with Greatest Element on Right Side Leetcode Solution196
655Find pairs with given sum such that elements of pair are in different rows196
656Painting Fence Algorithm195
657Word Wrap Problem195
658Find Pair with Greatest Product in Array195
659Merge Two Balanced Binary Search Trees195
660Longest Substring with At Most K Distinct Characters LeetCode Solution195
661Robot Room Cleaner Leetcode Solution195
662Maximum Consecutive Numbers Present in an Array195
663Strobogrammatic Number LeetCode Solution195
664House Robber195
665K Empty Slots LeetCode195
666Check If It Is a Straight Line Leetcode Solution195
667Reducing Dishes LeetCode Solution195
668Largest subarray with equal number of 0s and 1s194
669Kth Missing Positive Number Leetcode Solution194
670Queries for counts of array elements with values in given range194
671Partition Labels LeetCode Solution194
672Moving Average from Data Stream Leetcode Solution194
673Segregate 0s and 1s in an Array194
674Valid Palindrome II Leetcode Solution193
675Find Maximum Level sum in Binary Tree193
676Reservoir Sampling193
677Longest Span with same Sum in two Binary arrays193
678Find the node with minimum value in a Binary Search Tree193
679String to Integer (atoi) LeetCode Solution193
680Longest Substring with At Least K Repeating Characters LeetCode Solution193
681Distance of nearest cell having 1 in a binary matrix193
682Coin Change Problem193
683Sum of All Odd Length Subarrays Leetcode Solution193
684Maximum Product of Two Elements in an Array Leetcode Solution193
685Print the Fibonacci numbers in reverse order192
686Power of Four Leetcode Solution192
687Best Time to Buy and Sell Stock with Cooldown Leetcode Solution192
688String Compression LeetCode Solution192
689Flipping an Image LeetCode Solution192
690Find the Distance Value Between Two Arrays Leetcode Solution192
691Valid Palindrome192
692Partition Array Into Three Parts With Equal Sum Leetcode Solution192
693Dynamic Programming Basics192
694Find unique character in a string191
695Remove Invalid Parentheses Leetcode Solution191
696Check If Two String Arrays are Equivalent Leetcode Solution191
697Find the Smallest Divisor given a Threshold Leetcode Solution191
698Find Leaves of Binary Tree LeetCode Solution191
699Generate all possible sorted arrays from alternate elements of two given sorted arrays191
700Find the largest multiple of 3190
701Unique Paths II Leetcode Solution190
702Number of Dice Rolls With Target Sum LeetCode Solution190
703Reverse Only Letters LeetCode Solution190
704Numbers with prime frequencies greater than or equal to k190
705Inorder Successor of a node in Binary Tree190
706Wiggle Sort190
707Delete Nth node from the end of the given linked list190
708To Lower Case Leetcode Solution190
709Binary Tree Maximum Path Sum LeetCode Solution190
710Path With Maximum Minimum Value LeetCode Solution190
711Edit Distance LeetCode Solution189
712Lucky Numbers in a Matrix Leetcode Solution189
713Factorial Trailing Zeroes Leetcode Solution189
714Non-decreasing Array LeetCode Solution189
715Stack Permutations (Check if an array is stack permutation of other)189
716Subset Sum Leetcode189
717Find whether an array is subset of another array189
718Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest189
719Sort Array by Increasing Frequency Leetcode Solution189
720Maximum Number of Coins You Can Get Leetcode Solution189
721Increasing Decreasing String Leetcode Solution189
722Count quadruples from four sorted arrays whose sum is equal to a given value x188
723Recover Binary Search Tree188
724Populating Next Right Pointers in Each Node188
725Snakes and Ladders LeetCode Solution188
726Remove brackets from an algebraic string containing + and – operators188
727Bulb Switcher LeetCode Solution188
728k-th missing element in increasing sequence which is not present in a given sequence188
729Find if Path Exists in Graph Leetcode Solution188
730Merge Two Binary Trees LeetCode Solution188
731Perform String Shifts Leetcode188
732BFS vs DFS for Binary Tree188
733Permutation Sequence LeetCode Solution188
734Reversing a Queue using Recursion188
735Race Car LeetCode Solution188
736Find Maximum Depth of Nested Parenthesis in a String187
737Maximum 69 Number Leetcode Solution187
738Binary Tree Zigzag Level Order Traversal LeetCode Solution187
739Ugly Number Leetcode Solution187
740Maximum Length of a Concatenated String with Unique Characters Leetcode Solution187
741Majority Element II Leetcode Solution187
742Valid Perfect Square Leetcode Solution187
743Minimum Cost For Tickets Leetcode Solution187
744Evaluate Reverse Polish Notation LeetCode Solution187
745Best Meeting Point LeetCode Solution186
746Base 7 Leetcode Solution186
747Number of NGEs to the Right186
748Keyboard Row Leetcode Solution186
749Print a Binary Tree in Vertical Order186
750String comparison containing wildcards186
751Word Pattern LeetCode Solution186
752Student Attendance Record I Leetcode Solution186
753Merge Sorted Array LeetCode Solution186
754Tiling Problem186
755Valid Number186
756Find Median from Data Stream LeetCode Solution185
757Check if Two Expressions With Brackets are Same185
758Elements to be added so that all elements of a range are present in array185
759Binary Tree zigzag level order Traversal185
760Growable array based stack185
761N-Queens LeetCode Solution185
762Split a String in Balanced Strings Leetcode Solution185
763Morris Traversal185
764Program for Bridge and Torch problem185
765Rank Transform of an Array Leetcode Solution185
766Add and Search Word – Data structure design LeetCode185
767Finding K closest element185
768Maximum Profit in Job Scheduling Leetcode Solution185
769Restore IP Addresses Leetcode Solution185
770Maximum Product of Three Numbers LeetCode Solution185
771Symmetric Tree Leetcode Solution185
772Find All Possible Recipes from Given Supplies LeetCode Solution185
773Check If Array Pairs Are Divisible by k LeetCode Solution184
774Number of Days Between Two Dates LeetCode Solution184
775Hamming Distance Leetcode Solution184
776Binomial Coefficient184
777Partition to K Equal Sum Subsets Leetcode Solution184
778Sorted Linked List to Balanced BST184
779Construct BST from given Preorder Traversal184
780Regular Expression Matching184
781Brick Wall LeetCode Solution184
782Find All Duplicates in an Array LeetCode Solution184
783Top K Frequent Words LeetCode Solution184
784Special Array With X Elements Greater Than or Equal X Leetcode Solution184
785Priority Queue using doubly linked list184
786Minimize Maximum Pair Sum in Array LeetCode Solution184
787Minimum sum of multiplications of n numbers183
788Merge K Sorted Linked Lists183
789Check for Palindrome after every character replacement Query183
790Sort an array according to the order defined by another array183
791Minimum Distance Between BST Nodes Leetcode Solution183
792Form Minimum Number From Given Sequence183
793Search in a Binary Search Tree Leetcode Solution183
794Jump Game183
795Decompress Run-Length Encoded List Leetcode Solution183
796Largest Rectangle in Histogram LeetCode Solution183
797Maximum Difference Between Increasing Elements LeetCode Solution182
798Minimum Height Trees182
799Total Numbers With no Repeated Digits in a Range182
800Linked List Cycle182
801Largest rectangular sub-matrix whose sum is 0182
802Nearest Exit from Entrance in Maze LeetCode Solution182
803One Edit Distance LeetCode Solution182
804Kth ancestor of a node in binary tree182
805Invert Binary Tree LeetCode Solution182
806Maximum Depth of N-ary Tree Leetcode Solution182
807Queue based approach for first non-repeating character in a stream182
808Balanced Expression with Replacement181
809Minimum Time Visiting All Points Leetcode Solution181
810Maximum Nesting Depth of the Parentheses Leetcode Solution181
811Final Prices With a Special Discount in a Shop Leetcode Solution181
812Number of Islands II LeetCode Solution181
813Longest Subarray Having Count of 1s One More than Count of 0s181
814Circular Queue181
815Identify and Mark Unmatched Parenthesis in an Expression181
816Remove Nth Node From End of List Leetcode Solution181
817Count items common to both the lists but with different prices180
818Transpose Graph180
819Diagonal Traversal of Binary Tree180
820Relative Ranks Leetcode Solution180
821Given an Array of Pairs Find all Symmetric Pairs in it180
822Nested List Weight Sum II LeetCode Solution180
823Repeated Substring Pattern LeetCode Solution180
824Minimum time required to rot all oranges180
825Search a 2D Matrix II Leetcode Solution179
826Minimum Swaps to Make Strings Equal Leetcode Solution179
827Minimum Number of Taps to Open to Water a Garden LeetCode Solution179
828Deletion in a Binary Tree179
829Daily Temperatures Leetcode Solution179
830Crawler Log Folder Leetcode Solution179
831Reorder Data in Log Files LeetCode Solution178
832Course Schedule II – LeetCode178
833LCS (Longest Common Subsequence) of three strings178
834Sort Array By Parity II Leetcode Solution178
835Permutation Coefficient178
836Split Array Into Consecutive Subsequences178
837Number Complement Leetcode Solution178
838Design Browser History LeetCode Solution178
839Subarray Product Less Than K LeetCode Solution178
840Subsequence of Size K With the Largest Even Sum LeetCode Solution178
841Clone Graph LeetCode Solution178
842Minimum Jumps to Reach Home LeetCode Solution178
843Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution178
844A Space Optimized DP solution for 0-1 Knapsack Problem177
845Binary Search Tree Search and Insertion177
846Lemonade Change Leetcode Solution177
847Insert Delete GetRandom177
848Find all permuted rows of a given row in a matrix177
849Find Maximum Sum Possible Equal Sum of Three Stacks177
850Sliding Window Maximum177
851Check if stack elements are pairwise consecutive177
852Iterative Preorder Traversal177
853Last Stone Weight II LeetCode Solution177
854Check if an Array is Stack Sortable177
855Distinct adjacent elements in an array177
856Missing Element in Sorted Array LeetCode Solution177
857Matrix Chain Multiplication176
858Alien Dictionary LeetCode Solution176
859Minimum number of jumps to reach end176
860Find the Only Repetitive Element Between 1 to N-1176
861Remove Duplicates from Sorted List II176
862Check if a given array can represent Preorder Traversal of Binary Search Tree176
863Count Distinct Elements in Every Window of Size K176
864Valid Parentheses Leetcode Solution176
865Guess Number Higher or Lower LeetCode Solution176
866Tree Traversal (Preorder, Inorder & Postorder)176
867Path with maximum average value176
868An Interesting Method to generate Binary Numbers from 1 to n176
869Subset with sum divisible by m176
870Convert BST to Min Heap175
871Minimum swaps to make sequences increasing175
872Design a Stack With Increment Operation Leetcode Solution175
873Remove Duplicates from Sorted List LeetCode Solution175
874Union and Intersection of two Linked Lists175
875Dividing Array into Pairs With Sum Divisible by K175
876Sorted Array to Balanced BST175
877Interval Tree175
878Get Maximum in Generated Array Leetcode Solution175
879Find the subarray with least average175
880Minimum Sum Path in a Triangle175
881Partition List Leetcode Solution175
882Can Place Flowers LeetCode Solution175
883Sum of nearest smaller and greater number174
884Count ways to reach the nth stair using step 1, 2 or 3174
885Spiral Matrix II Leetcode Solution174
886Check whether a given Binary Tree is Complete or not174
887Minesweeper LeetCode Solution174
888Sort Colors174
889Infix to Postfix174
890Number of Distinct Islands Leetcode Solution174
891Brightest Position on Street LeetCode Solution174
892Level order Traversal in Spiral Form174
893Sequences of given length where every element is more than or equal to twice of previous174
894GCDs of given index ranges in an array174
895Find all triplets with zero sum173
896Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i173
897Find distance between two nodes of a Binary Tree173
898Range sum queries without updates173
899Guess Number Higher or Lower II173
900Friends Pairing Problem173
901Pattern Occurrences using Stack173
902Water Bottles Leetcode Solution173
903Maximum size subarray sum equals k173
904Least Number of Unique Integers after K Removals Leetcode Solution173
905Median of Two Sorted Arrays173
906Maximum Score After Splitting a String Leetcode Solution173
907Diagonal Traverse LeetCode Solution173
908Insert into a Binary Search Tree Leetcode Solution172
909Destination City Leetcode Solution172
910Lexicographical Numbers Leetcode Solution172
911Shortest Word Distance Leetcode Solution172
912Time Based Key-Value Store LeetCode Solution172
913Set Matrix Zeroes Leetcode Solution172
914Delete And Earn172
915Range LCM Queries172
916Iterative Postorder Traversal Using Two Stacks172
917Check if any two intervals overlap among a given set of intervals172
918Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution172
919Rearrange an Array Such that arr[i] is equal to i172
920Diagonal Traversal LeetCode Solution171
921Averages of Levels in Binary Tree171
922All Unique Triplets that Sum up to a Given Value171
923Alien Dictionary171
924Count Negative Numbers in a Sorted Matrix LeetCode Solution171
925Robot Bounded In Circle LeetCode Solution171
926A program to check if a binary tree is BST or not171
927Difference Array | Range update query in O(1)171
928Rearrange Spaces Between Words Leetcode Solution170
929Count Submatrices With All Ones LeetCode Solution170
930Spiral Matrix III LeetCode Solution170
931Check if the given array can represent Level Order Traversal of Binary Search Tree170
932K’th Largest Element in BST when modification to BST is not allowed170
933Three way partitioning of an array around a given range170
934Construct Complete Binary Tree from its Linked List Representation170
935My Calendar I LeetCode Solution170
936Construct the Rectangle Leetcode Solution170
937Binary Tree Longest Consecutive Sequence LeetCode Solution170
938Product of Array Except Self LeetCode Solution170
939Find Common Characters Leetcode Solution170
940Special Positions in a Binary Matrix Leetcode Solution170
941Binary array after M range toggle operations169
942Trim a Binary Search Tree169
943Create Maximum Number169
944Minimum Height Trees LeetCode Solution169
945Palindrome Partitioning Leetcode Solution169
946Queue using Stacks169
947Three Consecutive Odds Leetcode Solution169
948Intersection of Two Linked Lists LeetCode Solution169
949Maximum Frequency Stack Leetcode Solution169
950Convert Sorted List to Binary Search Tree169
951Number of Equivalent Domino Pairs Leetcode Solution169
952Count Subarrays with Same Even and Odd Elements169
953Merge Two Sorted Lists Leetcode169
954Vertical sum in a given binary tree169
955Largest area rectangular sub-matrix with equal number of 1’s and 0’s168
956Remove Duplicates from Sorted List II LeetCode Solution168
957Strongly Connected Component168
958Analyze User Website Visit Pattern LeetCode Solution168
959Word Break168
960Longest Palindromic Subsequence168
961Maximize Sum of Array after K Negations Leetcode Solution168
962BFS for Disconnected Graph168
964Kth Smallest Element in a BST Leetcode Solution167
965Count Primes in Ranges167
9663 Sum167
967Maximum Product Subarray167
968Queries for GCD of all numbers of an array except elements in a given range167
969Reverse Nodes in K-Group167
970Climbing stairs167
971Construct BST from its given Level Order Traversal167
972Sign of the Product of an Array LeetCode Solution167
973Unique Paths II166
974Depth First Search (DFS) for a Graph166
975Longest subsequence such that difference between adjacents is one166
976Count pair with Given Sum166
977Count subarrays where second highest lie before highest166
978Merging Intervals166
979Stone Game II Leetcode166
980Number of palindromic paths in a matrix166
981Combination Sum IV LeetCode Solution166
982Symmetric Tree166
983Breadth First Search (BFS) for a Graph165
984Find Maximum of Minimum for Every Window Size in a Given Array165
985Longest Nice Substring LeetCode Solution165
986Largest Number Leetcode Solution165
987Scramble String LeetCode Solution165
988The Maze III LeetCode Solution165
989Maximum Subarray Sum Excluding Certain Elements165
990Print Fibonacci sequence using 2 variables165
991Design Hit Counter LeetCode Solution165
992Serialize and Deserialize Binary Tree165
993Find the First Circular Tour that visits all the Petrol Pumps164
994Palindrome Partitioning164
995Height of a generic tree from parent array164
996Find number of pairs in an array such that their XOR is 0164
997Maximum Length of Repeated Subarray164
998String Matching in an Array Leetcode Solution164
999Maximum Product of Indexes of Next Greater on Left and Right164
1000Binary Search Tree Delete Operation164
1001Asteroid Collision LeetCode Solution164
1002Valid Boomerang Leetcode Solution164
1003Can Make Arithmetic Progression From Sequence Leetcode Solution164
1004Next Permutation Leetcode Solution163
1005Consecutive Characters LeetCode Solution163
1006Count pairs from two sorted arrays whose sum is equal to a given value x163
1007Print Next Greater Number of Q queries163
1008K maximum sums of overlapping contiguous sub-arrays163
1009K Closest Points to Origin Leetcode Solution163
1010Kth Smallest Element in a Sorted Matrix LeetCode Solution163
1011Shortest Completing Word Leetcode Solution163
1012Graph Valid Tree LeetCode Solution163
1013Length of Longest Fibonacci Subsequence162
1014Generate Parentheses Leetcode Solution162
1015Find the Difference Leetcode Solution162
1016Newman-Conway Sequence162
1017Invalid Transactions LeetCode Solution162
1018Balanced Binary Tree162
1019Shuffle 2n integers as without using extra space162
1020Maximum Sum of 3 Non-Overlapping Subarrays162
1021Minimum Index Sum of Two Lists162
1022Remove Duplicates from Sorted Array II Leetcode Solution162
1023The Painter’s Partition Problem162
1024Validate Binary Search Tree162
1025Find postorder traversal of BST from preorder traversal162
1026Collect maximum points in a grid using two traversals162
1027Largest Substring Between Two Equal Characters Leetcode Solution162
1028Maximum Number of Ways to Partition an Array LeetCode Solution162
1029Maximum difference between frequency of two elements such that element having greater frequency is also greater162
1030Level Order Traversal of Binary Tree162
1031Maximum length subsequence with difference between adjacent elements as either 0 or 1162
1032Decrypt String from Alphabet to Integer Mapping Leetcode Solution162
1033Largest divisible pairs subset161
1034Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’161
1035Friends Of Appropriate Ages LeetCode Solution161
1036Next Greater Element III LeetCode Solution161
1037Find Duplicate Subtrees161
1038Merge Sort161
1039Segment Tree161
1040Move all negative elements to end in order with extra space allowed161
1041Available Captures for Rook Leetcode Solution161
1042Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution161
1043Make The String Great Leetcode Solution161
1044Find a Peak Element II LeetCode Solution160
1045Advantages of BST over Hash Table160
1046Number Of Longest Increasing Subsequence160
1047Custom Sort String Leetcode Solution160
1048Compute nCr % p160
1049Binary Search Tree160
1050Construction of Longest Increasing Subsequence (N log N)160
1051Boolean Parenthesization Problem160
1052Insertion in a Binary Tree160
1053Bitwise AND of Numbers Range LeetCode Solution160
1054Construct Binary Tree from given Parent Array representation160
1055First missing positive160
1056Count minimum steps to get the given desired array159
1057Print Right View of a Binary Tree159
1058Kill Process LeetCode Solution159
1059Iterative Depth First Traversal of Graph159
1060Boundary Traversal of binary tree159
1061Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution159
1062Rearrange array such that even positioned are greater than odd159
1063Rearrange array such that even index elements are smaller and odd index elements are greater159
1064Path Sum II LeetCode Solution158
1065Minimum Size Subarray Sum158
1066Maximum subsequence sum such that no three are consecutive158
1067Subarrays with K Different Integers Leetcode Solution158
1068Largest BST Subtree LeetCode Solution158
1069Build an Array With Stack Operations Leetcode Solution158
1070Defanging an IP Address LeetCode Solution158
1071Double the first element and move zero to end158
1072Maximum weight transformation of a given string157
1073Employee Importance LeetCode Solution157
1074Recover Binary Search Tree Leetcode Solution157
1075Morris Inorder Traversal157
1076Add two numbers157
1077Remove Palindromic Subsequences Leetcode Solution157
1078Regular Expression Matching Regular Expression Matching LeetCode Solution157
1079Level order traversal using two Queues157
1080Find Peak Element157
1081Smallest Common Region Leetcode Solution156
1082Partition Equal Subset Sum156
1083Ugly Number II LeetCode Solution156
1084Implement Trie (Prefix Tree) Leetcode Solution156
1085Find maximum difference between nearest left and right smaller elements156
1086Palindrome Permutation LeetCode Solution156
1087Ugly Numbers156
1088Lowest Common Ancestor156
1089Longest Bitonic Subsequence155
1090Palindromic Substrings Leetcode Solution155
1091Increasing Triplet Subsequence LeetCode Solution155
1092Number of Closed Islands Leetcode Solution155
1093Maximize Distance to Closest Person LeetCode Solution155
1094Bus Routes Leetcode Solution155
1095Binary Tree Right Side View LeetCode Solution155
1096Remove duplicates from sorted array155
1097Super Ugly Number155
1098Populating Next Right Pointers in Each Node Leetcode Solution154
1099Find whether a subarray is in form of a mountain or not154
1100Number of siblings of a given Node in n-ary Tree154
1101Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution154
1102Path Sum154
1103Valid Tic-Tac-Toe State LeetCode Solution154
1104Sum of Even Numbers After Queries154
1105Divisible Pairs Counting154
1106Print all triplets in sorted array that form AP154
1107Search in Sorted Rotated Array153
1108Binary Tree Data Structure153
1109Iterative method to find ancestors of a given binary tree153
1110Moser-de Bruijn Sequence153
1111Find Three Element From Different Three Arrays Such That a + b + c = sum153
1112Reformat The String Leetcode Solution153
1113Find the minimum distance between two numbers153
1114Thousand Separator Leetcode Solution153
1115Level of Each node in a Tree from source node152
1116Number of Students Doing Homework at a Given Time Leetcode Solution152
1117Count Largest Group Leetcode Solution152
1118Cells with Odd Values in a Matrix LeetCode Solution152
1119Find Smallest Range Containing Elements from k Lists152
1120Search Insert Position152
1121Day of the Year Leetcode Solution152
1122Mean of Array After Removing Some Elements Leetcode Solution152
1123Kth Smallest Product of Two Sorted Arrays LeetCode Solution152
1124Minimum Absolute Difference in BST Leetcode Solution151
1125Longest Increasing Consecutive Subsequence151
1126Clone a Binary Tree with Random Pointers151
1127Products of ranges in an array151
1128Root to Leaf path with target sum Leetcode Solutions151
1129Distinct Subsequences151
1130Serialize and Deserialize Binary Tree LeetCode Solution151
1131Bottom View of a Binary Tree151
1132Maximum Product of Splitted Binary Tree LeetCode Solution150
1133Prime Palindrome LeetCode Solution150
1134Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution150
1135Find maximum length Snake sequence150
1136Constant time range add operation on an array150
1137Third Maximum Number Leetcode Solution150
1138Maximum Product Subarray150
1139Topological Sorting150
1140Compare Strings by Frequency of the Smallest Character Leetcode Solution150
1141Convert BST into a Min-Heap without using array150
1142Queries for Number of Distinct Elements in a Subarray149
1143Minimum Moves to Equal Array Elements LeetCode Solution149
1144Longest Repeated Subsequence149
1145Minimum sum of squares of character counts in a given string after removing k characters149
1146Construct K Palindrome Strings LeetCode Solution149
1147Maximum Depth Of Binary Tree149
1148Diameter of N-Ary Tree LeetCode Solution149
1149Write Code to Determine if Two Trees are Identical149
1150Count even length binary sequences with same sum of first and second half bits148
1151Golomb sequence148
1152Web Crawler LeetCode Solution148
1153Search an Element in Sorted Rotated Array148
1154Rotate Array148
1155Priority Queue148
1156Reformat Date LeetCode Solution148
1157Print modified array after executing the commands of addition and subtraction148
1158Longest Subarray of 1’s After Deleting One Element LeetCode Solution148
1159Minimum Score Triangulation of Polygon Leetcode Solution148
1160Find a sorted subsequence of size 3 in linear time147
1161Closest Binary Search Tree Value Leetcode Solution147
1162Cutting a Rod147
1163Delete Nodes and Return Forest Leetcode Solution147
1164Find Largest Value in Each Tree Row LeetCode Solution147
1165Subset Sum Problem in O(sum) space147
1166Closest Leaf in a Binary Tree LeetCode Solution147
1167Swap Nodes In Pairs146
1168Minimum Cost to Move Chips to The Same Position LeetCode Solution146
1169Maximize sum of consecutive differences in a circular array146
1170Kth Smallest Number in Multiplication Table Leetcode Solution146
1171Contiguous Array LeetCode Solution146
1172Red-Black Tree Introduction146
1173Count Pairs Whose Products Exist in Array146
1174Search Suggestions System LeetCode Solution146
1175Given a binary tree, how do you remove all the half nodes?146
1176Matchsticks to Square Leetcode Solution146
1177Possible Bipartition LeetCode Solution145
1178Transform a BST to Greater sum Tree145
1179Maximum sum of a path in a Right Number Triangle145
1180Minimum Swaps To Make Sequences Increasing LeetCode Solution145
1181Decision Tree145
1182Minimum Sideway Jumps LeetCode Solution145
1183K’th Largest element in BST using constant extra space145
1184Decrease Elements To Make Array Zigzag LeetCode Solution144
1185Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution144
1186Sum of Left Leaves LeetCode Solution144
1187Factorial Trailing Zeroes LeetCode Solution144
1188Find the smallest binary digit multiple of given number144
1189First Bad Version144
1190Replace two consecutive equal values with one greater144
1191Merge two BSTs with limited extra space144
1192Binary Tree to Binary Search Tree Conversion144
1193Reverse a Path in BST using Queue144
1194Path Crossing Leetcode Solution144
1195Maximum Binary Tree144
1196Maximum Value at a Given Index in a Bounded Array LeetCode Solution144
1197Check Array Formation Through Concatenation Leetcode Solution144
1198Number of Orders in the Backlog Leetcode Solution143
1199Maximum sum bitonic subarray143
1200Print n terms of Newman-Conway Sequence143
1201Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution143
1202Valid Triangle Number143
1203Maximum sum of pairs with specific difference143
1204Perfect Squares LeetCode Solution143
1205Maximum number of segments of lengths a, b and c143
1206Sliding Window Median Leetcode Solution142
1207Queue Reconstruction by Height142
1208Convert Sorted Array to Binary Search Tree LeetCode Solutions142
1209Divide Two Integers Leetcode Solution142
1210Queries on Probability of Even or Odd Number in given Ranges142
1211Concatenation of Array LeetCode Solution142
1212New 21 Game141
1213Guess The Word141
1214Swapping Nodes in a Linked List Leetcode Solution141
1215How to print maximum number of A’s using given four keys141
1216Integer Break LeetCode Solution141
1217Valid Perfect Square LeetCode Solution141
1218Graph and its representation140
1219Lowest Common Ancestor in Binary Search Tree140
1220Lowest Common Ancestor of a Binary Tree Leetcode Solution140
1221Array Queries for multiply replacements and product140
1222Champagne Tower LeetCode Solution140
1223Kth Smallest Element in a BST140
1224Moving Stones Until Consecutive Leetcode Solution139
1225Check if all levels of two Binary Tree are anagrams or not139
1226Find minimum number of merge operations to make an array palindrome139
1227Merge k Sorted Lists Leetcode Solution139
1228Maximum Array from Two given Arrays Keeping Order Same139
1229Longest Common Prefix Using Word by Word Matching139
1230Flatten 2D Vector LeetCode Solution139
1231Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution138
1232Mean of range in array138
1233Find Minimum in Rotated Sorted Array II LeetCode Solution138
1234Design Skiplist LeetCode Solution138
1235Range Sum Query using Sparse Table138
1236Missing Number137
1237Bold Words in String LeetCode Solution137
1238LRU Cache Leetcode Solution137
1239Write a function to get the intersection point of two Linked Lists137
1240BST to a Tree with Sum of all Smaller Keys137
1241Maximum Sum Increasing Subsequence137
1242Maximize Elements Using Another Array137
1243Range Queries for Longest Correct Bracket Subsequence137
1244Contiguous Array137
1245Print modified array after multiple array range increment operations137
1246The kth Factor of n Leetcode Solution136
1247Find k-th smallest element in BST (Order Statistics in BST)136
1248Maximum Product Subarray136
1249Largest Plus Sign Leetcode Solution136
1250Min Cost Climbing Stairs LeetCode Solution136
1251Minimum Remove to Make Valid Parentheses LeetCode Solution136
1252Parallel Courses II LeetCode Solution136
1253Count Subsets Having Distinct Even Numbers136
1254Power of Two135
1255Graph Cloning135
1256Check in binary array the number represented by a subarray is odd or even135
1257Arithmetic Slices II – Subsequence LeetCode Solution134
1258Different Ways to Add Parentheses Leetcode Solution134
1259Minimum Time to Collect All Apples in a Tree LeetCode Solution134
1260Check if each internal node of a BST has exactly one child134
1261Image Overlap LeetCode Solution134
1262Verify Preorder Serialization of a Binary Tree134
1263Check for Identical BSTs without building the trees133
1264Check if two nodes are on the same path in a Tree133
1265Orderly Queue LeetCode Solution132
1266Print Ancestors of a Given Binary Tree Node Without Recursion132
1267Symmetric Tree LeetCode Solution Leetcode Solution132
1268Check Completeness of a Binary Tree LeetCode Solution132
1269Smallest Range II Leetcode Solution132
1270Excel Sheet Column Title LeetCode Solution131
1271Koko Eating Bananas LeetCode Solution131
1272Next greater element131
1273Longest Substring Without Repeating Characters Leetcode Solution131
1274Arranging Coins Leetcode Solution130
1275Vertical Order Traversal of Binary Tree LeetCode Solution129
1276Number of elements less than or equal to a given number in a given subarray129
1277Count and Toggle Queries on a Binary Array129
1278Merge Sorted Array129
1279Largest Submatrix With Rearrangements LeetCode Solution128
1280Array Nesting Leetcode Solution127
1281Palindrome Partitioning127
1282Palindrome Number LeetCode Solution127
1283Peeking Iterator LeetCode Solution126
1284Add Two Numbers II Leetcode Solution126
1285Newman–Shanks–Williams prime126
1286Check If a String Can Break Another String Leetcode Solution126
1287Queries for Decimal Values of Subarrays of a Binary Array125
1288Range Minimum Query (Square Root Decomposition and Sparse Table)125
1289Find the Winner of the Circular Game LeetCode Solution125
1290Maximum product of an increasing subsequence125
1291Insert Delete GetRandom O(1) Leetcode Solution125
1292Check if X can give change to every person in the Queue125
1293Find maximum average subarray of k length124
1294Encoded String With Shortest Length LeetCode Solution123
1295Check given array of size n can represent BST of n levels or not123
1296Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution123
1297Continuous Subarray Sum LeetCode Solution121
1298Jump Game IV LeetCode Solution121
1299Random Pick Index LeetCode Solution121
1300Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution120
1301Minimum Number of People to Teach LeetCode Solution120
1302Number of indexes with equal elements in given range120
1303Reach a Number LeetCode Solution120
1304Binary Tree to Binary Search Tree Conversion using STL set120
1305Convert a BST to a Binary Tree such that sum of all greater keys is added to every key118
1306Minimum Total Space Wasted With K Resizing Operations LeetCode Solution117
1307Convert to Base -2 LeetCode Solution116
1308Design A Leaderboard Leetcode Solution115
1309Queries on XOR of greatest odd divisor of the range115
1310Design Underground System Leetcode Solution114
1311Shifting Letters LeetCode Solution112
1312Print Maximum Length Chain of Pairs111
1313Detect Capital Leetcode Solution111
1314Top K Frequent Elements LeetCode Solution110
1315Minimum Swaps to Group All 1’s Together Leetcode Solution110
1316Count Sub Islands LeetCode Solution108
1317Minimum Path Sum Leetcode Solution108
1318Substring with Concatenation of All Words Leetcode Solution106
1319Odd Even Linked List Leetcode Solution106
1320Monotonic Array Leetcode Solution105
1321Longest Common Subsequence LeetCode Solution102
1322Binary Tree Inorder Traversal LeetCode Solution101
1323Decode String Leetcode Solution101
1324Find the Town Judge LeetCode Solution100
1325Maximum Population Year LeetCode Solution100
1326Rectangle Overlap LeetCode Solution95
1327Shortest Unsorted Continuous Subarray LeetCode Solution95
1328Best Meeting Point LeetCode Solution94
1329Maximum Population Year LeetCode Solution93
1330Find the Town Judge LeetCode Solution92
1331Flatten Binary Tree to Linked List LeetCode Solution91
1332Insert into a Sorted Circular Linked List LeetCode Solution91
1333Sum Root to Leaf Numbers LeetCode Solution91
1334Design Add and Search Words Data Structure LeetCode Solution90
1335Reveal Cards In Increasing Order Leetcode Solution88
1336Stone Game IV LeetCode Solution88
1337Is Graph Bipartite? LeetCode Solution87
1338Range Sum Query 2D – Immutable LeetCode Solution87
1339Valid Triangle Number LeetCode Solution86
1340Score of Parenthesis LeetCode Solution85
1341Divide Chocolate LeetCode Solution81
1342Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution75
1343Range Sum of BST LeetCode Solution70
1344Reverse Integer Leetcode Solution67
1345Rotate String LeetCode Solution64
1346Find K Closest Elements LeetCode Solution64
1347Sort Colors LeetCode Solution63
1348Maximum Side Length of a Square with Sum Less than or Equal to Threshold LeetCode Solution61
1349Excel Sheet Column Number LeetCode Solution57
1350Maximum Size Subarray Sum Equals k Leetcode Solution50
1351H-Index Leetcode Solution46
1352Camelcase Matching Leetcode Solution45
1353Valid Anagram Leetcode Solution44
1354Most Stones Removed with Same Row or Column LeetCode Solution43
1355Container With Most Water LeetCode Solution43
1356Sliding Window Maximum LeetCode Solution42
1357High Five LeetCode Solution42
1358Group Anagrams LeetCode Solution42
1359Next Permutation LeetCode Solution41
1360Binary Search LeetCode Solution40
1361Find Peak Element LeetCode Solution40
1362Pairs of Songs With Total Durations Divisible by 60 LeetCode Solution39
1363Paint House LeetCode Solution37
1364Minimum Number of Arrows to Burst Balloons LeetCode Solution36
1365Valid Triangle Number LeetCode Solution36
1366Flatten Binary Tree to Linked List LeetCode Solution35
1367Isomorphic Strings LeetCode Solution35
1368Unique Binary Search Trees LeetCode Solution35
1369Next Greater Element I Leetcode Solution35
1370Group Shifted Strings Leetcode Solution34
1371Count Good Nodes in Binary Tree LeetCode Solution34
1372Sentence Screen Fitting LeetCode Solution33
1373The Number of Weak Characters in the Game LeetCode Solution33
1374Swim in Rising Water LeetCode Solution32
1375Insert Delete GetRandom O(1) – Duplicates allowed LeetCode Solution32
1376Closest Binary Search Tree Value II LeetCode Solution31
1377Peak Index in a Mountain Array LeetCode Solution31
1378Split Linked List in Parts Leetcode Solution30
1379Single Element in a Sorted Array LeetCode Solution29
1380Find First and Last Position of Element in Sorted Array LeetCode Solution27
1381All Possible Full Binary Trees LeetCode Solution27
1382Lowest Common Ancestor of a Binary Search Tree Leetcode Solution26
1383Validate Stack Sequences LeetCode Solution26
1384Minimum Increment to Make Array Unique Leetcode Solution26
1385Max Sum of Two Non-Overlapping Subarrays LeetCode Solution26
1386Implement strStr() LeetCode Solution25
1387Best Time to Buy and Sell Stock IV LeetCode Solution25
1388Break a Palindrome LeetCode Solution24
1389Implement Rand10() Using Rand7() Leetcode Solution24
1390Detect Squares LeetCode Solution24
1391Greatest Sum Divisible by Three LeetCode Solution24
1392Trapping Rain Water II LeetCode Solution23
1393Stone Game IV LeetCode Solution22
1394Invert Binary Tree LeetCode Solution22
1395Contains Duplicate LeetCode Solution22
1396Remove All Ones With Row and Column Flips Leetcode Solution21
1397Fibonacci Number LeetCode Solution20
1398Reverse Nodes in k-Group LeetCode Solution19
1399Design Bounded Blocking Queue LeetCode Solution18
1400Minimum Number of Operations to Move All Balls to Each Box LeetCode Solution17
1401Total Hamming Distance LeetCode Solution16
1402Candy LeetCode Solution16
1403Unique Paths III LeetCode Solution14
Translate »