Rotate String LeetCode Solution

Difficulty Level Easy
Frequently asked in Adobe Amazon Apple Bloomberg Cisco Goldman Sachs Google LinkedIn Microsoft Oracle Yahoo
String ZoomViews 32

Problem Statement

Rotate String LeetCode Solution – Given two strings s and goal, return true if and only ifcan become goal after some number of shifts on s.

shift on s consists of moving the leftmost character of s to the rightmost position.

  • For example, if s = “abcde”, then it will be “bcdea” after one shift.

 

Example 1:

Input:

 s = "abcde", goal = "cdeab"

Output:

 true

Approach

Idea:

We add s+s like in the first example abcde+abcde= abcdeabcde and clearly, we can see it contains all the left shift os s and simply we can return the contains method from it.

Code

Java Program of Rotate String:

class Solution {
public boolean rotateString(String s, String goal) 
{
    return (s.length()==goal.length() && (s+s).contains(goal));
}
}

Python Program of Rotate String:

class Solution :
    def  rotateString(self, s,  goal) :
        return (len(s) == len(goal) and  goal in (s + s) )

Complexity Analysis for Rotate String LeetCode Solution

Time Complexity

The time complexity of the above code is O(1) because we don’t do any traversing.

Space Complexity

The space complexity of the above code is O(1) because no matter how large our input is, the output always takes the same amount of space because of the way that it’s structured. Also, the output only needs to return true or false so the output itself isn’t derived by traversing anything.

Top Interview Questions

S.No Interview Question Number of times has been asked
1Delete a node in doubly linked list2819
2Java program to find the number of Nodes in a Binary Tree2500
3Reverse a string without affecting special characters2462
4Delete a node of a linked list at given position1976
5Palindrome using Recursion1780
6Insert nodes in a linked list in a sorted way (Ascending Order)1662
7Find elements pair from array whose sum equal to number1648
8Sort Elements by Frequency of Occurrences1631
9Write a program to print all permutations of a given string1606
10Find Minimum Distance Between Two Numbers in an Array1473
11Create a Doubly Linked List1444
12Quick Sort1420
13Reverse an Array1414
14Smallest window in a string containing all characters of another string1395
15Find a Triplet That Sum to a Given Value1356
16Recursively remove all adjacent duplicates1353
17First Repeating Element1337
18Arrange Even and Odd number such that Odd comes after Even1320
19Sum of numbers in String1317
20Smallest Positive Number Missing in an Unsorted Array1283
21Check if the Elements of an Array are Consecutive1253
22Detect a loop in the Linked List1237
23Largest Sum Contiguous Subarray1230
24Quick Sort on SIngly Linked List1214
25Subarray with Given Sum1213
26Print all Possible Combinations of R Elements in a given Array of size N1205
27Recursive function to do substring search1197
28Find the Maximum Repeating Number in Array1155
29Binary Tree Level order traversal in Java1124
30Find the First and Second Smallest Elements1121
31Check if two linked lists are identical1103
32Maximum Subarray Sum using Divide and Conquer1098
33Remove characters from first string which are in second1070
34Find Leaders in an Array1061
35Swap nodes in the linked list1036
36Find the Number Occurring Odd Number of Times in an Array1001
37Arrange given Numbers to Form the Biggest Number II993
38Find the second most frequent character990
39Given a string find its first non-repeating character970
40Find Triplet in Array With a Given Sum964
41Given a sorted array and a number x, find the pair in array whose sum is closest to x954
42Total number of occurrences of a given item in the linked list951
43A Program to check if strings are rotations of each other or not943
44Print all possible words from phone digits934
45Find the Missing Number926
46Rearrange Positive and Negative Numbers Alternatively in Array920
47Longest Palindromic Substring905
48Segregate even and odd nodes in a linked list883
49Print Longest common subsequence882
50Union and Intersection of Two Linked Lists871
51Transform one string to another using minimum number of given operations867
52Rearrange given Array in Maximum Minimum Form846
53Check rearranged string can form a palindrome845
54Count Possible Triangles819
55Iterative Implementation of Quick Sort816
56Multiplication of Two Matrices802
57Check if the linked list is palindrome795
58Count of Triplets With Sum Less than Given Value792
59Rotate a Linked List790
60Stock Buy Sell to Maximize Profit788
61Concatenation of two strings761
62Tug of War760
63Count Number of Substrings with K Distinct Character’s758
64Print all duplicates in the input string753
65Find Nearest Greater and Smaller Element746
66Find Pythagorean Triplets from Array736
67The Celebrity Problem736
68Reverse String Without Temporary Variable734
69Remove ‘b’ and ‘ac’ from a given string728
70Find all Common Elements in Given Three Sorted Arrays727
71Remove all duplicates in an unsorted linked list709
72Find the Row with Maximum Number of 1’s706
73Find the Peak Element from an Array699
74Find the subarray whose sum is equal to a given number X697
75Remove Minimum Characters so that Two Strings Become Anagrams689
76Find Smallest Missing Number in a Sorted Array687
77Insertion Sort686
78A Product Array Puzzle685
79Addition of Two Matrices682
80Implement Two Stacks in an Array676
81Generate all Binary Strings Without Consecutive 1’s672
82Maximum Sum of Non Consecutive Elements667
83Maximum Product Subarray II659
84Lexicographic rank of string654
85Check if Two given Matrices are Identical644
86Multiplication of Previous and Next644
87Subtraction of Two Matrices632
88Merge K Sorted Arrays and Print Sorted Output632
89Move All the Zeros to the End of the Given Array627
90Online Algorithm for Checking Palindrome in a Stream625
91Form Minimum Number from Given Sequence of D’s and I’s623
92Divide a string in N equal parts622
93Check whether two strings are anagram of each other614
94Maximum Circular Subarray Sum613
95Remove recurring digits in a given number609
96Sort a stack using a temporary stack608
97Sort a linked list that is sorted alternating ascending and descending608
98Find the Minimum Element in a Sorted and Rotated Array605
99Move last element of the Linked List at first place601
100Subarray and Subsequence600
101First Circular Tour to Visit all the Petrol Bunks600
102Largest Subarray with Equal Number of 0’s and 1’s597
103Compare two strings(linked lists)592
104Flattening a linked list591
105Maximum Element in an Array which is Increasing and then Decreasing590
106Palindrome Permutations of a String584
107Elements Appear more than N/K times in Array581
108Majority Element576
109Run length encoding575
110Minimum insertions to form a shortest palindrome573
111Print all permutations with repetition572
112Palindromes in a given range571
113Pangram Checking570
114Merge a linked list into another at alternate positions568
115Minimum Characters to be Added at Front to Make String Palindrome564
116Remove all duplicates in a sorted linked list563
117Rearrange a given linked list in-place562
118Minimum number of Merge Operations to make an Array Palindrome560
119Most repeating character in a string558
120Rotate string to get lexicographically minimum string557
121Repeated Subsequence of Length Two or More556
122Print all anagrams together in a sequence of words552
123Reorder an Array According to the Given Indexes550
124Pancake Sorting Problem542
125Merge Overlapping Intervals II539
126Two Sum Leetcode Solution539
127Clone a Linked List with next and random pointer536
128Size of The Subarray With Maximum Sum528
129Transpose of a Matrix524
130Removing Spaces from a String using stringstream521
131Remove Extra Spaces from a String520
132Remove duplicates from a string519
133Check if a given string is a rotation of a palindrome519
134Smallest Palindrome after Replacement518
135Partition Problem517
136Maximum Sum Increasing Subsequence515
137Longest Palindrome can be Formed by Removing or Rearranging Characters513
138Check whether Strings are K Distance Apart or Not502
139Generate all Binary Strings from Given Pattern502
140Delete Last Occurrence501
1413Sum Leetcode Solution500
142Length of Longest valid Substring499
143Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized499
144Insert Node in the Sorted Linked List498
145Check if Two given Strings are Isomorphic to each other494
146Maximum difference between two elements such as larger element comes after smaller487
147Program to Toggle all Characters in a String483
148Given string is interleaving of two other strings or not482
149Count Minimum Steps to Get the given Array480
150Number of Smaller Elements on Right Side478
151Merge sort better than quick sort for linked lists477
152Find Pair with Given Difference473
153Check if all Rows of a Matrix are Circular Rotations of Each Other471
154Check length of a String is Equal to the Number Appended at its Last470
155Longest Common Prefix using Divide and Conquer468
156Find nth node of the Linked list from the end466
157Find a Fixed Point in a Given Array463
158Sort 0s 1s and 2s in an Array458
159Print all interleavings of given two strings457
160Compare Two Version Numbers456
161Reverse words in a given string455
162Merge two sorted linked lists such that merged list is in reverse order453
163Find the Subarray of given length with Least Average452
164Reorder Array Using Given Indexes451
165Split linked list using alternate nodes450
166Median of Two Sorted Arrays LeetCode Solution450
167Print Reverse of a string (Recursion)449
168Find K Length Subarray of Maximum Average439
169Print string of odd length in ‘X’ format436
170Swap Kth Node from beginning with Kth Node from End433
171Find Element Using Binary Search in Sorted Array433
172Print all Palindromic Partitions of a String430
173Find Duplicates in an Array in Most Efficient Way428
174print all palindromic partitions421
175Maximum Length of Chain Pairs417
176Shortest Superstring Problem415
177Flatten a multilevel linked list415
178Check if String Follows Order of Characters by a Pattern or not412
179Sorting a K Sorted Array409
180Sort a String According to Another String404
181Longest Span with same Sum in two Binary Arrays II398
182Reverse a Linked List in groups395
183Find a Sorted Subsequence of size 3393
184Program to add two binary digits390
185Recursively print all the sentences that can be formed from list of word lists388
186Find the two Numbers with Odd Occurrences in an Unsorted Array387
187Longest Common Prefix Using Binary Search II385
188Reverse a Singly Linked List (Iterative/Non-Recursive)382
189Caesar Cipher378
190Rearrange a linked list in Zig-Zag378
191Check if String can Become Empty by Recursively Deleting given Substring378
192Kth Non-repeating Character377
193Pancake Sorting373
194Rotate Image by 90 degrees371
195Longest Common Prefix Word by Word Matching370
196Perfect Reversible String366
197Permutations of a Given String Using STL364
198Merging Two Sorted Arrays363
199Find the point where a monotonically increasing function becomes positive first time361
200Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes361
201Increasing Subsequence of Length three with Maximum Product361
202Find First non-repeating character in a string359
203Sort a linked list with 0s, 1s and 2s357
2041`s and 2`s complement of binary number357
205Four Elements that Sum to Given353
206Delete N nodes after M352
207List items containing all characters of a given word352
208Count Number of Occurrences in a Sorted Array350
209Longest Common Prefix using Character by Character Matching349
210Palindrome string (number)343
211Split a string342
212Minimum Characters to be Removed to Make a Binary String Alternate340
213Recursive Implementation of atoi()333
214Check if a Linked list of Strings form a Palindrome333
215Print All Distinct Elements of the Array332
216Sorting the array of strings330
217Convert a String that is Repetition of a Substring of Length K330
218Even Substring Count328
219Find the first Repeating Number in a Given Array326
220Maximum occurring character in a string326
221Valid Parentheses LeetCode Solution326
222Reverse a singly linked list recursively325
223Can we reverse a linked list in less than O(n) time ?323
224Binary Tree to Doubly linked list323
225Print Shortest Path to Print a String on Screen322
226Convert string1 to string2 in one edit319
227Maximum Subarray Leetcode Solution319
228wildcard character matching319
229Nth Character in Concatenated Decimal String318
230Reverse a String using Stack318
231Sort Elements by Frequency II317
232Lower Case To Upper Case314
233Count the number of words313
234Merge Two Sorted Arrays311
235Split Four Distinct Strings310
236Find the Lost Element From a Duplicated Array310
237Find middle of the Linked List307
238Longest Common Subsequence with Permutations306
239Count the Pairs at Same Distance as in English Alphabets301
240Matrix Chain Multiplication using Dynamic Programming297
241Next Greater Element in an Array294
242Palindrome Permutation290
243Find Nth Node285
244Roman to Integer Leetcode Solution285
245Find All Pairs With a Given Difference283
246Searching a node in a Binary Search Tree283
247Triplet from three linked lists with given sum280
248Delete a Tree280
249String(represents an integer) to value279
250Print all Possible Ways to Break a String in Bracket Form277
251Reverse a String276
252Reverse Bits275
253Delete a node under given conditions273
254Binary Tree273
255Word Search Leetcode Solution273
256How to Efficiently Implement k Stacks in a Single Array?272
257Change Gender of a given String271
258Sort an array of strings270
259Meeting Rooms II LeetCode Solution269
260Count Pairs With Given Sum269
261Number of sub-strings which recursively add up to 9268
262First non Repeating Element267
263Longest Common Extension267
264Remove middle points in a linked list of line segments266
265Repeated Substring Pattern263
266Toeplitz Matrix263
267Remove spaces from a string262
268Move all negative elements to one side of array262
269Longest Palindromic Substring LeetCode Solution262
270Shuffle a given Array258
271N queen problem258
272Min Stack257
273Dijkstra Algorithm252
274Number of Islands LeetCode Solution252
275Find, second, frequent, character251
276House Robber Leetcode Solution250
277Cuckoo sequence program250
278Clone a linked list with next and random pointer (Hashing)248
279Max stack248
280Most Frequent Element in an Array247
281Search Insert Position Leetcode Solution246
282Expression Evaluation245
283Minimize the maximum difference between the heights245
284Sort linked which is sorted on absolute values245
285KMP Algorithm242
286Subset Leetcode242
287Plus One Leetcode Solution242
288Valid Palindrome Leetcode Solution241
289Evaluation of Postfix Expression240
290Fibonacci numbers240
291Word Search239
292Min Stack Leetcode Solution239
293Sudoku Solver239
294Reverse words in a string239
295How to Delete a Linked List238
296Combination Sum Leetcode Solution237
297Number Of 1 bits236
298Merge Sorted Arrays Leetcode Solution233
299Sqrt(x) Leetcode Solution232
300Subarray with 0 sum230
301Set Matrix Zeroes230
302Backspace String Compare230
303Rabin Karp Algorithm228
304Contains Duplicate II Leetcode Solution228
305Reversing a Queue228
306Pair of Positive Negative Values in an Array227
307Tower Of Hanoi225
308Product of array except self225
309Combination Sum224
310Pascal Triangle Leetcode224
311Common elements in all rows of a given matrix223
312Integer to Roman Leetcode Solution223
313String Compression222
314Intersection of Two Arrays II Leetcode Solution222
315Delete middle element of a stack222
316Count subarrays with equal number of 1’s and 0’s221
317Minimum swaps required to bring all elements less than or equal to k together220
318Reverse individual words218
319Sliding Window Technique217
320Arithmetic Expression Evaluation217
321Pow(x, n) Leetcode Solution217
322Implementation of Deque using Doubly Linked List217
323Segregate even and odd numbers217
324Single Number Leetcode Solution217
325Add Binary Leetcode Solution217
326Construct Binary Tree from Given Inorder and Preorder Traversals216
327Second Most Repeated Word in a Sequence216
328Find Top K (or Most Frequent) Numbers in a Stream216
329Bellman Ford Algorithm216
330Count of index pairs with equal elements in an array215
331Palindrome Linked List Leetcode Solution215
332Design a stack that supports getMin() in O(1) time and O(1) extra space213
333Count Odd Numbers in an Interval Range Leetcode Solution213
334Next Permutation213
335Minimum Value to Get Positive Step by Step Sum Leetcode Solution212
336Maximum Number of Balloons Leetcode Solution212
337Contains Duplicate212
338Kruskal Algorithm211
339Page Replacement Algorithms in Operating Systems211
340Third Maximum Number Leetcode Solution211
341Postfix to Infix Conversion210
342Sort elements by frequency210
343Find Lucky Integer in an Array Leetcode Solution209
344Find sum of non-repeating elements (distinct) elements in an array209
345Permutations Leetcode Solution208
346K-th Smallest Element in a Sorted Matrix208
347Longest Common Prefix Leetcode Solution208
348Group Words With Same Set of Characters207
349Find the Town Judge Leetcode Solution207
350Convex Hull Algorithm207
351Majority Element Leetcode Solution206
352Find Numbers with Even Number of Digits Leetcode Solution206
353Sum of minimum and maximum elements of all subarrays of size k206
354Longest Substring Without Repeating Characters LeetCode Solution206
355Maximum Subarray206
356Sorting array using Stacks204
357Scramble String204
358Minimum operation to make all elements equal in array204
359Swap Nodes in Pairs Leetcode Solutions204
360Spiral Matrix LeetCode Solution204
361Count Primes Leetcode Solutions203
362Smallest Subarray with k Distinct Numbers203
363Top K Frequent Words203
364First element occurring k times in an array203
365Special Number202
366Check if two arrays are equal or not202
367Count subarrays having total distinct elements same as original array202
368Given two unsorted arrays find all pairs whose sum is x201
369Evaluate Division201
370Merge Two Sorted Lists Leetcode Solutions201
371Minimum Path Sum200
372Prefix to Infix Conversion200
373Pascal’s Triangle II Leetcode Solution200
374Number of Good Pairs Leetcode Solution200
375Power of Two Leetcode Solution200
376Best Time to Buy and Sell Stock  II Leetcode Solution200
377Reverse a Number Using Stack199
378Fizz Buzz Leetcode199
379Find All Numbers Disappeared in an Array Leetcode Solution198
380Reversing the First K elements of a Queue198
381Search in Rotated Sorted Array Leetcode Solution198
382Group Anagrams198
383House Robber II Leetcode Solution198
384Maximal Square197
385Missing Number Leetcode Solution197
386Minimum Steps to reach target by a Knight197
387Find duplicates in a given array when elements are not limited to a range197
388Minimum Absolute Difference Leetcode Solution196
389Leetcode Permutations196
390Huffman Coding196
391Matrix Diagonal Sum Leetcode Solution196
392Maximum possible difference of two subsets of an array196
393Running Sum of 1d Array Leetcode Solution195
394Unique Paths Leetcode Solution195
395Coin Change 2 Leetcode Solution195
396Top K Frequent Elements195
397How to Implement Stack Using Priority Queue or Heap?195
398Maximum Distance Between two Occurrences of Same Element in Array195
399How Many Numbers Are Smaller Than the Current Number Leetcode Solution194
400Expression Contains Redundant Bracket or Not194
401Single Number194
402Check if Array Contains Contiguous Integers With Duplicates Allowed194
403Sorting using trivial hash function193
404Max Consecutive Ones Leetcode Solution193
405Find The Duplicate Number193
406Remove Duplicates from Sorted Array Leetcode Solution193
407Length of the largest subarray with contiguous elements192
408Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution192
409Sort Array by Increasing Frequency Leetcode Solution192
410Range Sum Query 2D – Immutable Leetcode Solution192
411Find Number of Employees Under every Employee192
412Subarray Sum Equals k192
413Sort Integers by The Number of 1 Bit Leetcode Solution192
414Unique Paths192
415Decode String192
416Subarray Sum Equals K LeetCode Solution191
417Smallest Element Repeated Exactly K Times191
418Happy Number Leetcode Solution191
419Fibonacci Number LeetCode Solution191
420Find Winner on a Tic Tac Toe Game Leetcode Solution190
421Reverse Integer190
422Monotonic Array LeetCode Solution190
423Reverse Vowels of a String Leetcode Solution190
424Subtract the Product and Sum of Digits of an Integer Leetcode Solution190
425Zigzag Conversion190
426Find Median from data Stream190
427Find the Closest Palindrome number190
428Difference between highest and least frequencies in an array189
429Nth Catalan Number189
430Cumulative Frequency of Count of Each Element in an Unsorted Array189
431Shuffle the Array Leetcode Solution189
432Subset sum problem189
433Delete a Node from linked list without head pointer189
434Trapping Rain Water Leetcode Solution188
435LRU Cache Implementation188
436Count Substrings with equal number of 0s, 1s and 2s188
437Best Time to Buy and Sell Stock III Leetcode Solution188
438Check If N and Its Double Exist Leetcode Solution188
439Implement Stack and Queue using Deque188
440Palindrome Substring Queries188
441Find top three repeated in array187
442Maximum Depth of Binary Tree Leetcode Solution187
443Letter Case Permutation187
444Convert String To Int187
445Reverse Words in a String III LeetCode Solution187
446Print All Distinct Elements of a Given Integer Array187
447Subarrays with distinct elements187
448Integer to English words186
449Minimum Moves to Equal Array Elements Leetcode Solution186
450Kth largest element in an Array Leetcode Solutions186
451The K Weakest Rows in a Matrix Leetcode Solution186
452Find all pairs (a, b) in an array such that a % b = k186
453Find the Duplicate Element186
454Capacity To Ship Packages Within D Days Leetcode Solution186
455Sort a stack using recursion186
456Excel Sheet Column Number Leetcode Solution185
457Find the first repeating element in an array of integers185
458Reverse a Stack Using Recursion185
459Bipartite Graph185
460Iterative Tower of Hanoi185
461Find Minimum In Rotated Sorted Array184
462Sorting a Queue without Extra Space184
463Merge Two Sorted Linked Lists184
464Prim’s Algorithm184
465Generate a String With Characters That Have Odd Counts Leetcode Solution184
466Concatenation of Array LeetCode Solution184
467Count pairs from two linked lists whose sum is equal to a given value184
468Floyd Warshall Algorithm183
469Find the Difference Leetcode Solution183
470Priority Queue Using Singly Linked List183
471Find First and Last Position of Element in Sorted Array Leetcode Solution183
472Find Common Characters Leetcode Solution182
473Kth Largest Element in a Stream Leetcode Solution182
474Move Zeroes LeetCode Solution182
475Longest Common Subsequence182
476Word Ladder LeetCode Solution182
477Edit Distance182
478Next Greater Element I Leetcode Solution182
479Balanced Binary Tree Leetcode Solution182
480Flood Fill LeetCode182
481Multiply Strings Leetcode Solution182
482Reverse a String182
483Slowest Key Leetcode Solution182
484Merge Overlapping Intervals182
485Sum of Subarray Ranges Leetcode Solution182
486Text Justification LeetCode Solution181
487Fizz Buzz181
488Find elements which are present in first array and not in second181
489Number of Steps to Reduce a Number to Zero Leetcode Solution181
490Remove Minimum Number of Elements Such That no Common Element Exist in both Array181
491Kids With the Greatest Number of Candies Leetcode Solution181
492Count and Say181
493Top View of Binary Tree180
494Longest Common Prefix using Trie180
495Zigzag Conversion LeetCode Solution180
496Target Sum180
497Degree of an array180
498MiniMax Algorithm180
499Reverse a linked list180
500Print all subarrays with 0 sum180
501Jump Game Leetcode Solution179
502Convert array into Zig-Zag fashion179
503Design Parking System Leetcode Solution179
504Pair with given product178
505Intersection of Two Arrays178
506Longest subarray not having more than K distinct elements178
507Count and Say Leetcode Solution178
508Peak Index in a Mountain Array178
509Find subarray with given sum (Handles Negative Numbers)178
510Last Stone Weight177
511Valid Parenthesis String177
512Check if a given array contains duplicate elements within k distance from each other177
513Length of Last Word Leetcode Solution177
514Max Area of Island177
515Priority Queue in C++177
516Contiguous Array Leetcode176
517Koko Eating Bananas Leetcode Solution176
518Shuffle String Leetcode Solution176
519Shortest Palindrome176
520Find Index of Closing Bracket for a Given Opening Bracket in an Expression176
521Find four elements that sum to a given value (Hashmap)176
522Find missing elements of a range176
523Find N Unique Integers Sum up to Zero Leetcode Solution176
524The Stock Span Problem176
525Prefix to Postfix Conversion176
526Postfix to Prefix Conversion176
527Mobile Numeric Keypad Problem175
528Longest Common Prefix using Sorting175
529Substring With Concatenation Of All Words175
530Find distinct elements common to all rows of a matrix175
531Smallest Subarray With all Occurrences of a Most Frequent Element174
532N-th Tribonacci Number Leetcode Solution174
533Recursion174
534Iterative Inorder Traversal of a Binary Tree174
535Relative Sort Array Leetcode Solution174
536Largest Perimeter Triangle Leetcode Solution174
537Count number of triplets with product equal to given number174
538Implement a stack using single queue174
539K-th Distinct Element in an Array174
540Implementation of Deque using circular array174
541Find any one of the multiple repeating elements in read only array174
542Delete Node in a Linked List Leetcode Solution174
543Excel Sheet Column Title Leetcode Solution173
544Isomorphic Strings Leetcode Solution173
545Minimum Operations to convert X to Y173
546Valid Sudoku173
547Container with Most Water173
548Build Array From Permutation Leetcode Solution173
549Implement Stack using Queues173
550Is Subsequence Leetcode Solution173
551Valid Anagrams173
552Best Time to Buy and Sell Stock173
553Island Perimeter Leetcode Solution172
55401 Matrix LeetCode Solution172
555Next Greater Frequency Element172
556Maximum sum rectangle in a 2D matrix172
557Jewels and Stones Leetcode Solution172
558First negative integer in every window of size k172
559Sum of Left Leaves Leetcode Solutions172
560Linked List Cycle II LeetCode Solution172
561Distribute Candies to People Leetcode Solution172
562Convert Sorted Array to Binary Search Tree Leetcode Solution172
563Arrange given numbers to form the biggest number171
564Find Words That Can Be Formed by Characters Leetcode Solution171
565Trapping Rain Water LeetCode Solution171
566Convert a normal BST to Balanced BST171
567Remove Linked List Elements Leetcode Solution171
568Minimum Delete Operations to make all Elements of Array Same171
569Minimum Bracket Reversals170
570Shuffle an Array170
571Rearrange a binary string as alternate x and y occurrences170
572Count the number of nodes at given level in a tree using BFS170
573Insert Interval Leetcode Solution170
574Gold Mine Problem170
575Assign Cookies Leetcode Solution170
576Hamming Distance170
577Find the smallest positive integer value that cannot be represented as sum of any subset of a given array169
578Integer to Roman169
579Maximum path sum in a triangle169
5803Sum Closest LeetCode Solution169
581The Knapsack Problem169
582Check for Balanced Parentheses in an Expression169
583Count all subsequences having product less than K169
584Shortest Path in a Grid with Obstacles Elimination LeetCode Solution168
585Minimum Knight Moves LeetCode Solution168
586Group Multiple Occurrence of Array Elements Ordered by first Occurrence168
587Summary Ranges Leetcode Solution168
588LRU Cache LeetCode Solution168
589Change the Array into Permutation of Numbers From 1 to N168
590Rotate List Leetcode Solution168
591Minimum number of distinct elements after removing m items168
592Unique Binary Search Trees167
593XOR Operation in an Array Leetcode Solution167
594Decode Ways167
595K Empty Slots LeetCode167
596Segregate 0s and 1s in an Array167
597How to check if two given sets are disjoint?167
598Permutation in String Leetcode Solution167
599Combinations Leetcode Solution166
600Printing brackets in Matrix Chain Multiplication Problem166
601Rotate Image LeetCode Solution166
602Find if an Expression has Duplicate Parenthesis or Not166
603Same Tree LeetCode Solution166
604Maximum Distance in Array166
605Remove All Occurrences of a Substring LeetCode Solution166
606Sieve of Eratosthenes166
607Distance Between Bus Stops Leetcode Solution166
608Word Pattern165
609Maximum difference between first and last indexes of an element in array165
610Frog Jump Leetcode Solution165
611Find minimum difference between any two elements165
612Stone Game LeetCode165
613License Key Formatting Leetcode Solution165
614Sort Characters By Frequency LeetCode Solution165
615Painting Fence Algorithm164
616Replace Elements with Greatest Element on Right Side Leetcode Solution164
617Word Wrap Problem164
618Best Time to Buy and Sell Stock LeetCode Solution164
619Find the Duplicate Number LeetCode Solution164
620Minimum number of subsets with distinct elements164
621Find Sum of all unique sub-array sum for a given array164
622Minimum insertions to form a palindrome with permutations allowed164
623Applications of Breadth First Search and Depth First Search163
624Maximum Number of Chocolates to be Distributed Equally Among k Students163
625Smallest Good Base163
626Minimum Depth of Binary Tree Leetcode Solution163
627Longest Substring with At Most K Distinct Characters LeetCode Solution163
628Sort Array By Parity LeetCode Solution163
629Defanging an IP Address Leetcode Solution163
630Kth Missing Positive Number Leetcode Solution162
631Isomorphic Strings162
632Distance of nearest cell having 1 in a binary matrix162
633Find Maximum Level sum in Binary Tree162
634House Robber162
635Coin Change Problem162
636Valid Palindrome II Leetcode Solution161
637Iterative Method to find Height of Binary Tree161
638Tracking current Maximum Element in a Stack161
639Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest161
640Minimum Cost to Hire K Workers161
641Reverse a stack without using extra space in O(n)160
642GCD Of Two Numbers160
643Longest Increasing Subsequence160
644Delete consecutive same words in a sequence160
645Count Good Nodes in Binary Tree Leetcode Solution160
646Sum of All Odd Length Subarrays Leetcode Solution160
647Non-overlapping sum of two sets160
648Optimal Account Balancing LeetCode Solution160
649Binary Tree Zigzag Level Order Traversal LeetCode Solution160
650Check If It Is a Straight Line Leetcode Solution160
651Power of Four Leetcode Solution160
652Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions160
653Maximum Consecutive Numbers Present in an Array160
654Check If Two String Arrays are Equivalent Leetcode Solution159
655K Empty Slots159
656Moving Average from Data Stream Leetcode Solution159
657Number of Provinces Leetcode Solution159
658Best Time to Buy and Sell Stock with Cooldown Leetcode Solution159
659Merge Two Balanced Binary Search Trees159
660Convert an array to reduced form159
661Ugly Number Leetcode Solution159
662Largest Sum Contiguous Subarray158
663Maximum Number of Coins You Can Get Leetcode Solution158
664Letter Combinations of a Phone Number158
665Wiggle Sort158
666Check if a queue can be sorted into another queue using a stack158
667Reverse Only Letters LeetCode Solution158
668Strobogrammatic Number LeetCode Solution158
669String to Integer (atoi) LeetCode Solution158
670Employee Free Time LeetCode Solution158
671Number of Dice Rolls With Target Sum LeetCode Solution158
672Flipping an Image LeetCode Solution158
673Form minimum number from given sequence158
674Queries for counts of array elements with values in given range158
675Find Largest d in Array such that a + b + c = d157
676Reducing Dishes LeetCode Solution157
677Print the Fibonacci numbers in reverse order157
678Find the Smallest Divisor given a Threshold Leetcode Solution157
679Longest Increasing Path in a Matrix LeetCode Solution157
680Subset Sum Leetcode157
681Longest Substring with At Least K Repeating Characters LeetCode Solution157
682Sum of f(a[i], a[j]) over all pairs in an array of n integers157
683Construct BST from given Preorder Traversal157
684How to Create Mergable Stack?157
685Path With Maximum Minimum Value LeetCode Solution157
686To Lower Case Leetcode Solution157
687Inorder Successor of a node in Binary Tree157
688Increasing Decreasing String Leetcode Solution157
689Partition Labels LeetCode Solution157
690Lucky Numbers in a Matrix Leetcode Solution157
691Reorganize String157
692Find whether an array is subset of another array156
693Find the Distance Value Between Two Arrays Leetcode Solution156
694Unique Paths II Leetcode Solution156
695Maximum Number of Occurrences of a Substring Leetcode Solution156
696Find Leaves of Binary Tree LeetCode Solution156
697Reversing a Queue using Recursion156
698Valid Perfect Square Leetcode Solution156
699Robot Room Cleaner Leetcode Solution156
700Valid Palindrome156
701Find pairs with given sum such that elements of pair are in different rows155
702Delete Nth node from the end of the given linked list155
703Permutation Sequence LeetCode Solution155
704Merge Two Binary Trees LeetCode Solution155
705Edit Distance LeetCode Solution155
706Dynamic Programming Basics155
707Populating Next Right Pointers in Each Node155
708Recover Binary Search Tree155
709Binary Tree zigzag level order Traversal155
710Partition Array Into Three Parts With Equal Sum Leetcode Solution155
711Keyboard Row Leetcode Solution155
712Majority Element II Leetcode Solution155
713Remove Invalid Parentheses Leetcode Solution155
714Maximum Product of Two Elements in an Array Leetcode Solution155
715Reservoir Sampling155
716BFS vs DFS for Binary Tree155
717Maximum Product of Three Numbers LeetCode Solution154
718Restore IP Addresses Leetcode Solution154
719Find the node with minimum value in a Binary Search Tree154
720Decompress Run-Length Encoded List Leetcode Solution154
721Rank Transform of an Array Leetcode Solution154
722Add and Search Word – Data structure design LeetCode154
723Sort Array by Increasing Frequency Leetcode Solution154
724Hamming Distance Leetcode Solution154
725Convert a Number to Hexadecimal Leetcode Solution153
726Factorial Trailing Zeroes Leetcode Solution153
727Numbers with prime frequencies greater than or equal to k153
728String Compression LeetCode Solution153
729Stack Permutations (Check if an array is stack permutation of other)153
730Bulb Switcher LeetCode Solution152
731Sorted Linked List to Balanced BST152
732Longest Span with same Sum in two Binary arrays152
733Queue based approach for first non-repeating character in a stream152
734Find the largest multiple of 3152
735Deletion in a Binary Tree152
736Binary Tree Maximum Path Sum LeetCode Solution152
737Find unique character in a string152
738Symmetric Tree Leetcode Solution152
739Best Meeting Point LeetCode Solution152
740Check If Array Pairs Are Divisible by k LeetCode Solution151
741Non-decreasing Array LeetCode Solution151
742Race Car LeetCode Solution151
743Minimum Cost For Tickets Leetcode Solution151
744Find All Duplicates in an Array LeetCode Solution151
745Generate all possible sorted arrays from alternate elements of two given sorted arrays151
746Invert Binary Tree LeetCode Solution151
747Largest subarray with equal number of 0s and 1s151
748Binomial Coefficient151
749Word Pattern LeetCode Solution151
750Search in a Binary Search Tree Leetcode Solution151
751Find Maximum Depth of Nested Parenthesis in a String151
752Finding K closest element151
753Find Median from Data Stream LeetCode Solution151
754Minimum Distance Between BST Nodes Leetcode Solution151
755Maximum 69 Number Leetcode Solution151
756Minimum Height Trees151
757Linked List Cycle151
758Find if Path Exists in Graph Leetcode Solution150
759Perform String Shifts Leetcode150
760Search a 2D Matrix II Leetcode Solution150
761First Unique Character in a String LeetCode Solution150
762Maximum Length of a Concatenated String with Unique Characters Leetcode Solution150
763Number of Islands II LeetCode Solution150
764Minimize Maximum Pair Sum in Array LeetCode Solution150
765Remove Duplicates from Sorted List LeetCode Solution150
766Find Pair with Greatest Product in Array150
767Remove Nth Node From End of List Leetcode Solution150
768Maximum Depth of N-ary Tree Leetcode Solution150
769Student Attendance Record I Leetcode Solution150
770Bubble sort using two Stacks150
771Count quadruples from four sorted arrays whose sum is equal to a given value x150
772N-Queens LeetCode Solution150
773k-th missing element in increasing sequence which is not present in a given sequence150
774Largest rectangular sub-matrix whose sum is 0149
775Maximum Difference Between Increasing Elements LeetCode Solution149
776Diagonal Traversal of Binary Tree149
777Kth ancestor of a node in binary tree149
778Morris Traversal149
779Evaluate Reverse Polish Notation LeetCode Solution149
780Growable array based stack149
781Merge K Sorted Linked Lists149
782Jump Game149
783Split a String in Balanced Strings Leetcode Solution149
784Elements to be added so that all elements of a range are present in array149
785Final Prices With a Special Discount in a Shop Leetcode Solution148
786Valid Number148
787Largest Rectangle in Histogram LeetCode Solution148
788Number Complement Leetcode Solution148
789Minimum number of jumps to reach end148
790Minimum Time Visiting All Points Leetcode Solution148
791Snakes and Ladders LeetCode Solution148
792Transpose Graph148
793Minimum time required to rot all oranges148
794Program for Bridge and Torch problem148
795Remove brackets from an algebraic string containing + and – operators148
796Crawler Log Folder Leetcode Solution147
797Sort an array according to the order defined by another array147
798Get Maximum in Generated Array Leetcode Solution147
799Number of NGEs to the Right147
800Tiling Problem147
801Remove Duplicates from Sorted List II147
802Regular Expression Matching147
803Nested List Weight Sum II LeetCode Solution147
804Special Array With X Elements Greater Than or Equal X Leetcode Solution147
805Nearest Exit from Entrance in Maze LeetCode Solution147
806Merge Sorted Array LeetCode Solution147
807Check for Palindrome after every character replacement Query147
808Count items common to both the lists but with different prices147
809Relative Ranks Leetcode Solution147
810Check if Two Expressions With Brackets are Same147
811Minimum Jumps to Reach Home LeetCode Solution147
812Minimum Number of Taps to Open to Water a Garden LeetCode Solution146
813Sort Colors146
814Circular Queue146
815Interval Tree146
816Sort Array By Parity II Leetcode Solution146
817Maximum size subarray sum equals k146
818Subarray Product Less Than K LeetCode Solution146
819String comparison containing wildcards146
820Longest Subarray Having Count of 1s One More than Count of 0s146
821Print a Binary Tree in Vertical Order146
822Reorder Data in Log Files LeetCode Solution146
823Convert BST to Min Heap146
824Base 7 Leetcode Solution146
825One Edit Distance LeetCode Solution146
826Friends Pairing Problem146
827A Space Optimized DP solution for 0-1 Knapsack Problem146
828Partition to K Equal Sum Subsets Leetcode Solution146
829Find the subarray with least average145
830Check if a given array can represent Preorder Traversal of Binary Search Tree145
831Maximum Profit in Job Scheduling Leetcode Solution145
832Alien Dictionary LeetCode Solution145
833Path with maximum average value145
834Priority Queue using doubly linked list145
835Subsequence of Size K With the Largest Even Sum LeetCode Solution145
836Minimum swaps to make sequences increasing145
837Sorted Array to Balanced BST145
838Clone Graph LeetCode Solution145
839Minimum Swaps to Make Strings Equal Leetcode Solution144
840Total Numbers With no Repeated Digits in a Range144
841Insert into a Binary Search Tree Leetcode Solution144
842Find the Only Repetitive Element Between 1 to N-1144
843Iterative Preorder Traversal144
844Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution144
845Last Stone Weight II LeetCode Solution144
846Course Schedule II – LeetCode144
847Count Distinct Elements in Every Window of Size K144
848Level order Traversal in Spiral Form144
849Design a Stack With Increment Operation Leetcode Solution144
850Partition List Leetcode Solution144
851Brightest Position on Street LeetCode Solution144
852Guess Number Higher or Lower LeetCode Solution144
853Check if an Array is Stack Sortable143
854Permutation Coefficient143
855Top K Frequent Words LeetCode Solution143
856Brick Wall LeetCode Solution143
857Subset with sum divisible by m143
858Union and Intersection of two Linked Lists143
859Can Place Flowers LeetCode Solution143
860Minimum Sum Path in a Triangle143
861Repeated Substring Pattern LeetCode Solution143
862Valid Parentheses Leetcode Solution143
863Three way partitioning of an array around a given range143
864Find all triplets with zero sum143
865Maximum Nesting Depth of the Parentheses Leetcode Solution143
866Lemonade Change Leetcode Solution142
867Water Bottles Leetcode Solution142
868Find All Possible Recipes from Given Supplies LeetCode Solution142
869Form Minimum Number From Given Sequence142
870Given an Array of Pairs Find all Symmetric Pairs in it142
871Check whether a given Binary Tree is Complete or not142
872Matrix Chain Multiplication141
873Design Browser History LeetCode Solution141
874Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution141
875Spiral Matrix II Leetcode Solution141
876Tree Traversal (Preorder, Inorder & Postorder)141
8774Sum141
878Range sum queries without updates141
879Count ways to reach the nth stair using step 1, 2 or 3141
880Binary Search Tree Search and Insertion141
881Rearrange Spaces Between Words Leetcode Solution141
882LCS (Longest Common Subsequence) of three strings141
883Sum of nearest smaller and greater number141
884Identify and Mark Unmatched Parenthesis in an Expression141
885Balanced Expression with Replacement141
886GCDs of given index ranges in an array141
887Daily Temperatures Leetcode Solution141
888Least Number of Unique Integers after K Removals Leetcode Solution141
889Shortest Word Distance Leetcode Solution140
890Distinct adjacent elements in an array140
891Insert Delete GetRandom140
892Special Positions in a Binary Matrix Leetcode Solution140
893An Interesting Method to generate Binary Numbers from 1 to n140
894Construct Complete Binary Tree from its Linked List Representation140
895Sequences of given length where every element is more than or equal to twice of previous140
896Destination City Leetcode Solution140
897Queries for GCD of all numbers of an array except elements in a given range140
898Delete And Earn140
899Diagonal Traversal LeetCode Solution140
900Find Maximum Sum Possible Equal Sum of Three Stacks140
901Guess Number Higher or Lower II140
902Find all permuted rows of a given row in a matrix140
903Count Negative Numbers in a Sorted Matrix LeetCode Solution140
904Robot Bounded In Circle LeetCode Solution140
905BFS for Disconnected Graph140
906Missing Element in Sorted Array LeetCode Solution140
907Count Subarrays with Same Even and Odd Elements140
908Number of Days Between Two Dates LeetCode Solution140
909Maximum Score After Splitting a String Leetcode Solution140
910Minimum sum of multiplications of n numbers139
911Check if the given array can represent Level Order Traversal of Binary Search Tree139
912Alien Dictionary139
913A program to check if a binary tree is BST or not139
914Time Based Key-Value Store LeetCode Solution139
915Set Matrix Zeroes Leetcode Solution139
916Check if stack elements are pairwise consecutive139
917Convert Sorted List to Binary Search Tree139
918Rearrange an Array Such that arr[i] is equal to i139
919Palindrome Partitioning Leetcode Solution138
920Vertical sum in a given binary tree138
921Range LCM Queries138
922Number of Distinct Islands Leetcode Solution138
923Diagonal Traverse LeetCode Solution138
924Find Common Characters Leetcode Solution138
925Find distance between two nodes of a Binary Tree138
926Analyze User Website Visit Pattern LeetCode Solution138
927Merge Two Sorted Lists Leetcode137
928K’th Largest Element in BST when modification to BST is not allowed137
929Longest Palindromic Subsequence137
930Can Make Arithmetic Progression From Sequence Leetcode Solution137
931Stone Game II Leetcode137
932Merging Intervals137
933Remove Duplicates from Sorted List II LeetCode Solution137
934Spiral Matrix III LeetCode Solution137
9353 Sum137
936Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i137
937Maximum Subarray Sum Excluding Certain Elements136
938Maximum Frequency Stack Leetcode Solution136
939Maximize Sum of Array after K Negations Leetcode Solution136
940Infix to Postfix136
941Number of Equivalent Domino Pairs Leetcode Solution136
942Word Break136
943Queue using Stacks136
944Intersection of Two Linked Lists LeetCode Solution136
945Averages of Levels in Binary Tree136
946Sliding Window Maximum136
947Construct the Rectangle Leetcode Solution136
948Three Consecutive Odds Leetcode Solution136
949Lexicographical Numbers Leetcode Solution136
950Print Fibonacci sequence using 2 variables136
951Largest area rectangular sub-matrix with equal number of 1’s and 0’s136
952Strongly Connected Component136
953Count Submatrices With All Ones LeetCode Solution135
954Reverse Nodes in K-Group135
955Difference Array | Range update query in O(1)135
956Pattern Occurrences using Stack135
957Trim a Binary Search Tree135
958Breadth First Search (BFS) for a Graph135
959Binary Tree Longest Consecutive Sequence LeetCode Solution135
960Construct BST from its given Level Order Traversal135
961Binary array after M range toggle operations135
962Median of Two Sorted Arrays135
963Dividing Array into Pairs With Sum Divisible by K135
964All Unique Triplets that Sum up to a Given Value135
965Minimum Height Trees LeetCode Solution135
966Check if any two intervals overlap among a given set of intervals135
967Largest divisible pairs subset134
968Find Maximum of Minimum for Every Window Size in a Given Array134
969Height of a generic tree from parent array134
970Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution134
971Largest Substring Between Two Equal Characters Leetcode Solution134
972Palindrome Partitioning134
973Split Array Into Consecutive Subsequences134
974Count Primes in Ranges134
975Symmetric Tree134
976Find postorder traversal of BST from preorder traversal134
977Create Maximum Number134
978Newman-Conway Sequence134
979K Closest Points to Origin Leetcode Solution133
980Product of Array Except Self LeetCode Solution133
981Sign of the Product of an Array LeetCode Solution133
982Binary Search Tree Delete Operation133
983First missing positive133
984Find Duplicate Subtrees133
985Kth Smallest Element in a BST Leetcode Solution133
986Asteroid Collision LeetCode Solution133
987Iterative Postorder Traversal Using Two Stacks133
988Maximum Product Subarray133
989Count pair with Given Sum133
990Minesweeper LeetCode Solution133
991Depth First Search (DFS) for a Graph133
992Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space133
993Segment Tree133
994Find the First Circular Tour that visits all the Petrol Pumps132
995The Maze III LeetCode Solution132
996Boundary Traversal of binary tree132
997Find the Difference Leetcode Solution132
998My Calendar I LeetCode Solution132
999The Painter’s Partition Problem132
1000Kill Process LeetCode Solution132
1001Level Order Traversal of Binary Tree132
1002Length of Longest Fibonacci Subsequence132
1003Climbing stairs132
1004Rearrange array such that even positioned are greater than odd132
1005Unique Paths II132
1006Serialize and Deserialize Binary Tree132
1007Maximum subsequence sum such that no three are consecutive132
1008Graph Valid Tree LeetCode Solution131
1009Partition Equal Subset Sum131
1010Next Greater Element III LeetCode Solution131
1011Maximum Number of Ways to Partition an Array LeetCode Solution131
1012Longest Nice Substring LeetCode Solution131
1013Decrypt String from Alphabet to Integer Mapping Leetcode Solution131
1014Build an Array With Stack Operations Leetcode Solution131
1015Count subarrays where second highest lie before highest131
1016Double the first element and move zero to end131
1017Longest subsequence such that difference between adjacents is one131
1018Make The String Great Leetcode Solution131
1019Super Ugly Number130
1020Shortest Completing Word Leetcode Solution130
1021Morris Inorder Traversal130
1022Insertion in a Binary Tree130
1023Maximum Length of Repeated Subarray130
1024Collect maximum points in a grid using two traversals130
1025Find number of pairs in an array such that their XOR is 0130
1026Largest Number Leetcode Solution130
1027Boolean Parenthesization Problem130
1028Level order traversal using two Queues130
1029Valid Boomerang Leetcode Solution130
1030String Matching in an Array Leetcode Solution129
1031Design Hit Counter LeetCode Solution129
1032Advantages of BST over Hash Table129
1033Ugly Number II LeetCode Solution129
1034Balanced Binary Tree129
1035Friends Of Appropriate Ages LeetCode Solution129
1036Number Of Longest Increasing Subsequence129
1037Compute nCr % p129
1038Recover Binary Search Tree Leetcode Solution129
1039Binary Search Tree129
1040Validate Binary Search Tree128
1041Kth Smallest Element in a Sorted Matrix LeetCode Solution128
1042Invalid Transactions LeetCode Solution128
1043Construction of Longest Increasing Subsequence (N log N)128
1044Employee Importance LeetCode Solution128
1045Number of palindromic paths in a matrix128
1046Implement Trie (Prefix Tree) Leetcode Solution128
1047Defanging an IP Address LeetCode Solution128
1048Available Captures for Rook Leetcode Solution128
1049Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’128
1050Maximum length subsequence with difference between adjacent elements as either 0 or 1128
1051Scramble String LeetCode Solution128
1052Ugly Numbers128
1053Move all negative elements to end in order with extra space allowed128
1054Minimum Size Subarray Sum128
1055Construct Binary Tree from given Parent Array representation128
1056Maximum Product of Indexes of Next Greater on Left and Right128
1057Maximum weight transformation of a given string127
1058Maximum difference between frequency of two elements such that element having greater frequency is also greater127
1059Count minimum steps to get the given desired array127
1060Longest Bitonic Subsequence127
1061Populating Next Right Pointers in Each Node Leetcode Solution127
1062Find Peak Element127
1063Add two numbers127
1064Regular Expression Matching Regular Expression Matching LeetCode Solution127
1065Increasing Triplet Subsequence LeetCode Solution127
1066Minimum Index Sum of Two Lists127
1067Find whether a subarray is in form of a mountain or not127
1068Maximum Sum of 3 Non-Overlapping Subarrays127
1069Iterative Depth First Traversal of Graph127
1070Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution126
1071Bitwise AND of Numbers Range LeetCode Solution126
1072Maximize Distance to Closest Person LeetCode Solution126
1073Find the minimum distance between two numbers126
1074Divisible Pairs Counting126
1075Generate Parentheses Leetcode Solution126
1076Count pairs from two sorted arrays whose sum is equal to a given value x126
1077Remove Duplicates from Sorted Array II Leetcode Solution126
1078Day of the Year Leetcode Solution126
1079Custom Sort String Leetcode Solution126
1080Lowest Common Ancestor126
1081Clone a Binary Tree with Random Pointers126
1082Path Sum II LeetCode Solution126
1083Find a Peak Element II LeetCode Solution126
1084Combination Sum IV LeetCode Solution126
1085Path Sum125
1086Binary Tree Data Structure125
1087Search in Sorted Rotated Array125
1088Number of Closed Islands Leetcode Solution125
1089Binary Tree Right Side View LeetCode Solution125
1090Largest BST Subtree LeetCode Solution125
1091Smallest Common Region Leetcode Solution125
1092Remove Palindromic Subsequences Leetcode Solution124
1093Consecutive Characters LeetCode Solution124
1094Find Smallest Range Containing Elements from k Lists124
1095Rearrange array such that even index elements are smaller and odd index elements are greater124
1096Subarrays with K Different Integers Leetcode Solution124
1097Kth Smallest Product of Two Sorted Arrays LeetCode Solution124
1098Level of Each node in a Tree from source node124
1099Find maximum difference between nearest left and right smaller elements124
1100Print Next Greater Number of Q queries124
1101Types of Binary Tree124
1102Next Permutation Leetcode Solution124
1103Print all triplets in sorted array that form AP124
1104Number of Students Doing Homework at a Given Time Leetcode Solution124
1105Number of siblings of a given Node in n-ary Tree124
1106Serialize and Deserialize Binary Tree LeetCode Solution123
1107Topological Sorting123
1108Distinct Subsequences123
1109Find Three Element From Different Three Arrays Such That a + b + c = sum123
1110Third Maximum Number Leetcode Solution123
1111Convert BST into a Min-Heap without using array122
1112Write Code to Determine if Two Trees are Identical122
1113Bottom View of a Binary Tree122
1114Maximum Binary Tree122
1115Constant time range add operation on an array122
1116Remove duplicates from sorted array122
1117Minimum Absolute Difference in BST Leetcode Solution122
1118Print Right View of a Binary Tree122
1119Cutting a Rod122
1120Maximum Product Subarray122
1121Root to Leaf path with target sum Leetcode Solutions122
1122Reformat The String Leetcode Solution121
1123Minimum Score Triangulation of Polygon Leetcode Solution121
1124Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution121
1125Cells with Odd Values in a Matrix LeetCode Solution121
1126Mean of Array After Removing Some Elements Leetcode Solution121
1127Valid Tic-Tac-Toe State LeetCode Solution121
1128Count Largest Group Leetcode Solution121
1129Closest Binary Search Tree Value Leetcode Solution120
1130Construct K Palindrome Strings LeetCode Solution120
1131Products of ranges in an array120
1132Search an Element in Sorted Rotated Array120
1133Longest Subarray of 1’s After Deleting One Element LeetCode Solution120
1134Search Insert Position120
1135Minimum sum of squares of character counts in a given string after removing k characters120
1136Palindrome Permutation LeetCode Solution120
1137Thousand Separator Leetcode Solution120
1138Iterative method to find ancestors of a given binary tree120
1139Golomb sequence120
1140Sum of Even Numbers After Queries120
1141Queries for Number of Distinct Elements in a Subarray120
1142Moser-de Bruijn Sequence119
1143Print modified array after executing the commands of addition and subtraction119
1144Longest Increasing Consecutive Subsequence119
1145Find a sorted subsequence of size 3 in linear time119
1146Red-Black Tree Introduction119
1147Prime Palindrome LeetCode Solution119
1148Factorial Trailing Zeroes LeetCode Solution119
1149Merge two BSTs with limited extra space118
1150Maximum Product of Splitted Binary Tree LeetCode Solution118
1151Find maximum length Snake sequence118
1152Bus Routes Leetcode Solution118
1153Subset Sum Problem in O(sum) space118
1154Delete Nodes and Return Forest Leetcode Solution118
1155Binary Tree to Binary Search Tree Conversion118
1156Transform a BST to Greater sum Tree118
1157Swapping Nodes in a Linked List Leetcode Solution117
1158Count even length binary sequences with same sum of first and second half bits117
1159Decision Tree117
1160K maximum sums of overlapping contiguous sub-arrays117
1161Number of Orders in the Backlog Leetcode Solution117
1162Possible Bipartition LeetCode Solution117
1163Check Array Formation Through Concatenation Leetcode Solution117
1164Kth Smallest Number in Multiplication Table Leetcode Solution117
1165K’th Largest element in BST using constant extra space117
1166Swap Nodes In Pairs117
1167Find the smallest binary digit multiple of given number117
1168Palindromic Substrings Leetcode Solution117
1169Longest Repeated Subsequence117
1170Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution117
1171Compare Strings by Frequency of the Smallest Character Leetcode Solution117
1172Maximize sum of consecutive differences in a circular array116
1173Minimum Sideway Jumps LeetCode Solution116
1174Rotate Array116
1175Minimum Cost to Move Chips to The Same Position LeetCode Solution116
1176Priority Queue116
1177Minimum Moves to Equal Array Elements LeetCode Solution116
1178Web Crawler LeetCode Solution116
1179Find Largest Value in Each Tree Row LeetCode Solution115
1180Search Suggestions System LeetCode Solution115
1181Decrease Elements To Make Array Zigzag LeetCode Solution115
1182First Bad Version115
1183Closest Leaf in a Binary Tree LeetCode Solution115
1184Count Pairs Whose Products Exist in Array115
1185Moving Stones Until Consecutive Leetcode Solution114
1186Diameter of N-Ary Tree LeetCode Solution114
1187Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution114
1188Queue Reconstruction by Height114
1189Contiguous Array LeetCode Solution114
1190Given a binary tree, how do you remove all the half nodes?114
1191Maximum sum bitonic subarray113
1192Lowest Common Ancestor in Binary Search Tree113
1193Kth Smallest Element in a BST113
1194Convert Sorted Array to Binary Search Tree LeetCode Solutions113
1195Valid Triangle Number113
1196How to print maximum number of A’s using given four keys113
1197Maximum number of segments of lengths a, b and c113
1198Reverse a Path in BST using Queue113
1199Maximum Depth Of Binary Tree113
1200Matchsticks to Square Leetcode Solution113
1201Divide Two Integers Leetcode Solution112
1202Sum of Left Leaves LeetCode Solution112
1203Longest Common Prefix Using Word by Word Matching112
1204Reformat Date LeetCode Solution112
1205Champagne Tower LeetCode Solution112
1206Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution112
1207Write a function to get the intersection point of two Linked Lists112
1208Integer Break LeetCode Solution112
1209Array Queries for multiply replacements and product112
1210Guess The Word111
1211Range Queries for Longest Correct Bracket Subsequence111
1212Range Sum Query using Sparse Table111
1213New 21 Game111
1214Maximum sum of pairs with specific difference111
1215Replace two consecutive equal values with one greater111
1216Path Crossing Leetcode Solution110
1217Arithmetic Slices II – Subsequence LeetCode Solution110
1218Design Skiplist LeetCode Solution110
1219Concatenation of Array LeetCode Solution110
1220Valid Perfect Square LeetCode Solution110
1221Maximum Value at a Given Index in a Bounded Array LeetCode Solution110
1222Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution110
1223Graph and its representation110
1224Symmetric Tree LeetCode Solution Leetcode Solution110
1225Print modified array after multiple array range increment operations110
1226The kth Factor of n Leetcode Solution109
1227Sliding Window Median Leetcode Solution109
1228Merge Sort109
1229Minimum Swaps To Make Sequences Increasing LeetCode Solution109
1230Perfect Squares LeetCode Solution109
1231Lowest Common Ancestor of a Binary Tree Leetcode Solution109
1232Maximum sum of a path in a Right Number Triangle109
1233BST to a Tree with Sum of all Smaller Keys109
1234Check Completeness of a Binary Tree LeetCode Solution109
1235Check if each internal node of a BST has exactly one child109
1236Maximum Array from Two given Arrays Keeping Order Same109
1237Flatten 2D Vector LeetCode Solution109
1238Check for Identical BSTs without building the trees109
1239Check if all levels of two Binary Tree are anagrams or not108
1240Parallel Courses II LeetCode Solution108
1241Count Subsets Having Distinct Even Numbers108
1242Mean of range in array108
1243LRU Cache Leetcode Solution108
1244Queries on Probability of Even or Odd Number in given Ranges108
1245Print n terms of Newman-Conway Sequence108
1246Power of Two108
1247Maximum Product Subarray107
1248Find Minimum in Rotated Sorted Array II LeetCode Solution107
1249Maximize Elements Using Another Array107
1250Missing Number107
1251Contiguous Array107
1252Image Overlap LeetCode Solution107
1253Count and Toggle Queries on a Binary Array107
1254Largest Plus Sign Leetcode Solution107
1255Graph Cloning107
1256Find minimum number of merge operations to make an array palindrome106
1257Check If a String Can Break Another String Leetcode Solution106
1258Bold Words in String LeetCode Solution106
1259Next greater element105
1260Excel Sheet Column Title LeetCode Solution105
1261Minimum Remove to Make Valid Parentheses LeetCode Solution105
1262Find k-th smallest element in BST (Order Statistics in BST)105
1263Verify Preorder Serialization of a Binary Tree105
1264Merge k Sorted Lists Leetcode Solution104
1265Print Ancestors of a Given Binary Tree Node Without Recursion104
1266Min Cost Climbing Stairs LeetCode Solution104
1267Smallest Range II Leetcode Solution104
1268Minimum Time to Collect All Apples in a Tree LeetCode Solution103
1269Palindrome Partitioning103
1270Check if two nodes are on the same path in a Tree102
1271Check in binary array the number represented by a subarray is odd or even102
1272Merge Sorted Array101
1273Orderly Queue LeetCode Solution101
1274Koko Eating Bananas LeetCode Solution100
1275Different Ways to Add Parentheses Leetcode Solution100
1276Peeking Iterator LeetCode Solution100
1277Newman–Shanks–Williams prime99
1278Check if X can give change to every person in the Queue99
1279Number of elements less than or equal to a given number in a given subarray99
1280Longest Substring Without Repeating Characters Leetcode Solution98
1281Find maximum average subarray of k length97
1282Maximum Sum Increasing Subsequence97
1283Range Minimum Query (Square Root Decomposition and Sparse Table)97
1284Largest Submatrix With Rearrangements LeetCode Solution97
1285Queries for Decimal Values of Subarrays of a Binary Array96
1286Array Nesting Leetcode Solution96
1287Minimum Total Space Wasted With K Resizing Operations LeetCode Solution96
1288Number of indexes with equal elements in given range96
1289Minimum Number of People to Teach LeetCode Solution95
1290Maximum product of an increasing subsequence95
1291Binary Tree to Binary Search Tree Conversion using STL set94
1292Check given array of size n can represent BST of n levels or not94
1293Arranging Coins Leetcode Solution94
1294Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution93
1295Random Pick Index LeetCode Solution93
1296Find the Winner of the Circular Game LeetCode Solution92
1297Add Two Numbers II Leetcode Solution92
1298Jump Game IV LeetCode Solution92
1299Encoded String With Shortest Length LeetCode Solution92
1300Queries on XOR of greatest odd divisor of the range92
1301Convert a BST to a Binary Tree such that sum of all greater keys is added to every key92
1302Convert to Base -2 LeetCode Solution92
1303Reach a Number LeetCode Solution92
1304Insert Delete GetRandom O(1) Leetcode Solution90
1305Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution89
1306Palindrome Number LeetCode Solution88
1307Vertical Order Traversal of Binary Tree LeetCode Solution87
1308Continuous Subarray Sum LeetCode Solution87
1309Design Underground System Leetcode Solution86
1310Print Maximum Length Chain of Pairs85
1311Detect Capital Leetcode Solution82
1312Design A Leaderboard Leetcode Solution81
1313Top K Frequent Elements LeetCode Solution79
1314Substring with Concatenation of All Words Leetcode Solution79
1315Minimum Swaps to Group All 1’s Together Leetcode Solution78
1316Minimum Path Sum Leetcode Solution75
1317Decode String Leetcode Solution74
1318Count Sub Islands LeetCode Solution73
1319Odd Even Linked List Leetcode Solution72
1320Binary Tree Inorder Traversal LeetCode Solution72
1321Maximum Population Year LeetCode Solution71
1322Shifting Letters LeetCode Solution71
1323Shortest Unsorted Continuous Subarray LeetCode Solution71
1324Best Meeting Point LeetCode Solution71
1325Find the Town Judge LeetCode Solution70
1326Longest Common Subsequence LeetCode Solution70
1327Sum Root to Leaf Numbers LeetCode Solution70
1328Design Add and Search Words Data Structure LeetCode Solution68
1329Find the Town Judge LeetCode Solution68
1330Rectangle Overlap LeetCode Solution66
1331Maximum Population Year LeetCode Solution66
1332Score of Parenthesis LeetCode Solution65
1333Insert into a Sorted Circular Linked List LeetCode Solution63
1334Stone Game IV LeetCode Solution62
1335Flatten Binary Tree to Linked List LeetCode Solution62
1336Is Graph Bipartite? LeetCode Solution60
1337Range Sum Query 2D – Immutable LeetCode Solution60
1338Valid Triangle Number LeetCode Solution59
1339Reveal Cards In Increasing Order Leetcode Solution55
1340Divide Chocolate LeetCode Solution51
1341Range Sum of BST LeetCode Solution43
1342Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution42
1343Reverse Integer Leetcode Solution41
1344Sort Colors LeetCode Solution37
1345Find K Closest Elements LeetCode Solution36
1346Excel Sheet Column Number LeetCode Solution34
1347Rotate String LeetCode Solution32
1348Maximum Side Length of a Square with Sum Less than or Equal to Threshold LeetCode Solution31
Translate »