Camelcase Matching Leetcode Solution

Difficulty Level Medium
Frequently asked in Amazon Google JP Morgan
StringViews 4

Problem Statement:

Camelcase Matching Leetcode Solution says that – Given an array of string “queries” and string “pattern”, return boolean array result where result[i] is true where “queries[i]” matches with “pattern”, false otherwise.

A query word “queries[i]” matches with “pattern” if you can insert some lowercase English letters in “pattern” so that it equals the query. You may insert each character at any position or you may not insert any characters.

Examples:

Example 1:

Input: 
queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FB"
Output: 
[true,false,true,true,false]

Explanation:

Camelcase Matching Leetcode SolutionPin

 

Example 2:

Input: 
queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FoBa"
Output: 
[true,false,true,false,false]

Approach:

Idea:

For each string in queries, we compare it with the pattern and if both match we push “true” in the result array otherwise we push “false” in the result.

  1. First, we iterate through the given queries, and for each string in the queries, we check if it matches the pattern or not.
  2. For checking, we start with index=0 which represents the character to match in the pattern.
  3. Now loop all characters in the string to be matched with the pattern.
  4. Whenever we encounter a character that is equal to pattern[index], increase index=index+1.
  5. If the character encountered is uppercase and it doesn’t match the pattern[index] returns false.
  6. Return true after all characters in the string are traversed and only if the index value is equal to the length of the Pattern.

Code:

C++ code:

class Solution {
public:
    bool isCheck(string query, string pattern){
        int i=0;
        for(auto c:query){
            if(i<pattern.size() && c==pattern[i]) i++;
            else if(c>='A' && c<='Z') return false;
        }
        if(i==pattern.size()) return true;
        return false;
    }
    vector<bool> camelMatch(vector<string>& queries, string pattern) {
        vector<bool> result;
        for(auto i:queries){
            if(isCheck(i, pattern)){
                result.push_back(true);
            }
            else{
                result.push_back(false);
            }
        }
        return result;
    }
};

Java code:

class Solution {
    public Boolean isCheck(String query, String pattern){
        int i=0;
        for(int c=0;c<query.length();c++){
            if(i<pattern.length() && query.charAt(c)==pattern.charAt(i)) i++;
            else if(query.charAt(c) >= 'A' && query.charAt(c) <= 'Z') return false;
        }
        if(i==pattern.length()) return true;
        return false;
    }
    public List<Boolean> camelMatch(String[] queries, String pattern) {
        List<Boolean> result = new ArrayList<>();
        for(int i=0;i<queries.length;i++){
            if(isCheck(queries[i], pattern)){
                result.add(true);
            }
            else{
                result.add(false);
            }
        }
        return result;
    }
}

Complexity Analysis for Camelcase Matching Leetcode Solution:

Time Complexity:

The time complexity will be O(N*M) where N = the length of the “queries” and M= the length of the “pattern”.

Space Complexity:

The space complexity will be O(1) since no extra space is required.

Similar type of question for reference and practice:

String matching in array

 

Top Interview Questions

S.No Interview Question Number of times has been asked
1Delete a node in doubly linked list2831
2Java program to find the number of Nodes in a Binary Tree2508
3Reverse a string without affecting special characters2469
4Delete a node of a linked list at given position1982
5Palindrome using Recursion1882
6Insert nodes in a linked list in a sorted way (Ascending Order)1668
7Find elements pair from array whose sum equal to number1655
8Sort Elements by Frequency of Occurrences1640
9Write a program to print all permutations of a given string1614
10Quick Sort1545
11Find Minimum Distance Between Two Numbers in an Array1479
12Create a Doubly Linked List1454
13Reverse an Array1417
14Smallest window in a string containing all characters of another string1402
15Find a Triplet That Sum to a Given Value1364
16Recursively remove all adjacent duplicates1362
17First Repeating Element1346
18Arrange Even and Odd number such that Odd comes after Even1327
19Sum of numbers in String1324
20Smallest Positive Number Missing in an Unsorted Array1292
21Check if the Elements of an Array are Consecutive1261
22Detect a loop in the Linked List1246
23Largest Sum Contiguous Subarray1235
24Quick Sort on SIngly Linked List1223
25Subarray with Given Sum1217
26Print all Possible Combinations of R Elements in a given Array of size N1209
27Recursive function to do substring search1206
28Find the Maximum Repeating Number in Array1160
29Binary Tree Level order traversal in Java1130
30Find the First and Second Smallest Elements1126
31Check if two linked lists are identical1112
32Maximum Subarray Sum using Divide and Conquer1108
33Remove characters from first string which are in second1076
34Find Leaders in an Array1064
35Swap nodes in the linked list1043
36Find the Number Occurring Odd Number of Times in an Array1008
37Arrange given Numbers to Form the Biggest Number II997
38Find the second most frequent character994
39Given a string find its first non-repeating character975
40Find Triplet in Array With a Given Sum968
41Total number of occurrences of a given item in the linked list959
42Given a sorted array and a number x, find the pair in array whose sum is closest to x959
43A Program to check if strings are rotations of each other or not952
44Print all possible words from phone digits939
45Find the Missing Number930
46Rearrange Positive and Negative Numbers Alternatively in Array925
47Longest Palindromic Substring910
48Segregate even and odd nodes in a linked list892
49Print Longest common subsequence888
50Union and Intersection of Two Linked Lists879
51Transform one string to another using minimum number of given operations873
52Check rearranged string can form a palindrome855
53Rearrange given Array in Maximum Minimum Form851
54Iterative Implementation of Quick Sort839
55Count Possible Triangles825
56Multiplication of Two Matrices808
57Check if the linked list is palindrome801
58Count of Triplets With Sum Less than Given Value800
59Rotate a Linked List800
60Stock Buy Sell to Maximize Profit797
61Insertion Sort770
62Concatenation of two strings768
63Tug of War766
64Print all duplicates in the input string762
65Count Number of Substrings with K Distinct Character’s761
66Find Nearest Greater and Smaller Element751
67The Celebrity Problem744
68Find Pythagorean Triplets from Array742
69Reverse String Without Temporary Variable737
70Remove ‘b’ and ‘ac’ from a given string737
71Find all Common Elements in Given Three Sorted Arrays734
72Remove all duplicates in an unsorted linked list714
73Find the Row with Maximum Number of 1’s712
74Find the Peak Element from an Array704
75Find the subarray whose sum is equal to a given number X701
76Remove Minimum Characters so that Two Strings Become Anagrams697
77Find Smallest Missing Number in a Sorted Array691
78Addition of Two Matrices691
79A Product Array Puzzle689
80Generate all Binary Strings Without Consecutive 1’s683
81Implement Two Stacks in an Array681
82Maximum Sum of Non Consecutive Elements675
83Lexicographic rank of string661
84Maximum Product Subarray II661
85Multiplication of Previous and Next653
86Check if Two given Matrices are Identical653
87Subtraction of Two Matrices641
88Merge K Sorted Arrays and Print Sorted Output638
89Move All the Zeros to the End of the Given Array637
90Divide a string in N equal parts631
91Online Algorithm for Checking Palindrome in a Stream629
92Form Minimum Number from Given Sequence of D’s and I’s628
93Remove recurring digits in a given number622
94Check whether two strings are anagram of each other621
95Maximum Circular Subarray Sum616
96Sort a linked list that is sorted alternating ascending and descending615
97Sort a stack using a temporary stack613
98Find the Minimum Element in a Sorted and Rotated Array610
99Move last element of the Linked List at first place610
100Subarray and Subsequence606
101First Circular Tour to Visit all the Petrol Bunks604
102Largest Subarray with Equal Number of 0’s and 1’s602
103Compare two strings(linked lists)599
104Flattening a linked list599
105Maximum Element in an Array which is Increasing and then Decreasing596
106Palindrome Permutations of a String591
107Palindromes in a given range584
108Elements Appear more than N/K times in Array584
109Print all permutations with repetition583
110Majority Element582
111Run length encoding582
112Pangram Checking578
113Minimum insertions to form a shortest palindrome578
114Minimum Characters to be Added at Front to Make String Palindrome570
115Merge a linked list into another at alternate positions570
116Rearrange a given linked list in-place569
117Most repeating character in a string569
118Remove all duplicates in a sorted linked list569
119Minimum number of Merge Operations to make an Array Palindrome567
120Rotate string to get lexicographically minimum string564
121Repeated Subsequence of Length Two or More561
122Print all anagrams together in a sequence of words559
123Reorder an Array According to the Given Indexes557
124Pancake Sorting Problem548
125Two Sum Leetcode Solution544
126Clone a Linked List with next and random pointer542
127Merge Overlapping Intervals II542
1283Sum Leetcode Solution539
129Transpose of a Matrix533
130Size of The Subarray With Maximum Sum532
131Remove Extra Spaces from a String529
132Removing Spaces from a String using stringstream527
133Remove duplicates from a string526
134Check if a given string is a rotation of a palindrome525
135Partition Problem524
136Longest Palindrome can be Formed by Removing or Rearranging Characters523
137Smallest Palindrome after Replacement523
138Maximum Sum Increasing Subsequence522
139Check whether Strings are K Distance Apart or Not514
140Generate all Binary Strings from Given Pattern510
141Length of Longest valid Substring508
142Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized506
143Insert Node in the Sorted Linked List506
144Delete Last Occurrence504
145Check if Two given Strings are Isomorphic to each other500
146Maximum difference between two elements such as larger element comes after smaller494
147Program to Toggle all Characters in a String492
148Given string is interleaving of two other strings or not489
149Count Minimum Steps to Get the given Array485
150Merge sort better than quick sort for linked lists482
151Number of Smaller Elements on Right Side481
152Find Pair with Given Difference480
153Check length of a String is Equal to the Number Appended at its Last479
154Check if all Rows of a Matrix are Circular Rotations of Each Other477
155Longest Common Prefix using Divide and Conquer475
156Find nth node of the Linked list from the end473
157Find a Fixed Point in a Given Array467
158Sort 0s 1s and 2s in an Array466
159Print all interleavings of given two strings464
160Compare Two Version Numbers464
161Reverse words in a given string462
162Find the Subarray of given length with Least Average461
163Print Reverse of a string (Recursion)459
164Reorder Array Using Given Indexes459
165Merge two sorted linked lists such that merged list is in reverse order459
166Split linked list using alternate nodes457
167Median of Two Sorted Arrays LeetCode Solution456
168Print string of odd length in ‘X’ format445
169Find K Length Subarray of Maximum Average440
170Print all Palindromic Partitions of a String440
171Find Element Using Binary Search in Sorted Array439
172Swap Kth Node from beginning with Kth Node from End437
173Find Duplicates in an Array in Most Efficient Way433
174print all palindromic partitions426
175Flatten a multilevel linked list423
176Shortest Superstring Problem421
177Maximum Length of Chain Pairs420
178Check if String Follows Order of Characters by a Pattern or not418
179Sorting a K Sorted Array415
180Sort a String According to Another String412
181Longest Span with same Sum in two Binary Arrays II404
182Reverse a Linked List in groups401
183Find a Sorted Subsequence of size 3400
184Recursively print all the sentences that can be formed from list of word lists398
185Program to add two binary digits397
186Find the two Numbers with Odd Occurrences in an Unsorted Array394
187Longest Common Prefix Using Binary Search II392
188Reverse a Singly Linked List (Iterative/Non-Recursive)389
189Caesar Cipher388
190Kth Non-repeating Character386
191Rearrange a linked list in Zig-Zag385
192Check if String can Become Empty by Recursively Deleting given Substring383
193Longest Common Prefix Word by Word Matching380
194Pancake Sorting380
195Rotate Image by 90 degrees380
196Permutations of a Given String Using STL373
197Perfect Reversible String371
198Increasing Subsequence of Length three with Maximum Product368
199Merging Two Sorted Arrays368
200Sort a linked list with 0s, 1s and 2s365
2011`s and 2`s complement of binary number365
202Find First non-repeating character in a string365
203Find the point where a monotonically increasing function becomes positive first time364
204Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes363
205Four Elements that Sum to Given362
206List items containing all characters of a given word360
207Delete N nodes after M357
208Longest Common Prefix using Character by Character Matching353
209Count Number of Occurrences in a Sorted Array351
210Palindrome string (number)349
211Split a string347
212Minimum Characters to be Removed to Make a Binary String Alternate343
213Recursive Implementation of atoi()341
214Check if a Linked list of Strings form a Palindrome340
215Print All Distinct Elements of the Array338
216Sorting the array of strings337
217Even Substring Count336
218Maximum occurring character in a string334
219Convert a String that is Repetition of a Substring of Length K334
220Find the first Repeating Number in a Given Array333
221Valid Parentheses LeetCode Solution333
222Reverse a singly linked list recursively331
223Can we reverse a linked list in less than O(n) time ?329
224Print Shortest Path to Print a String on Screen329
225Convert string1 to string2 in one edit327
226Binary Tree to Doubly linked list326
227Reverse a String using Stack326
228wildcard character matching325
229Sort Elements by Frequency II323
230Nth Character in Concatenated Decimal String323
231Maximum Subarray Leetcode Solution321
232Count the number of words318
233Lower Case To Upper Case318
234Merge Two Sorted Arrays316
235Split Four Distinct Strings315
236Find the Lost Element From a Duplicated Array313
237Find middle of the Linked List311
238Longest Common Subsequence with Permutations309
239Count the Pairs at Same Distance as in English Alphabets307
240Matrix Chain Multiplication using Dynamic Programming302
241Next Greater Element in an Array301
242Palindrome Permutation295
243Roman to Integer Leetcode Solution292
244Find Nth Node291
245Find All Pairs With a Given Difference290
246Searching a node in a Binary Search Tree288
247Triplet from three linked lists with given sum286
248Delete a Tree283
249Reverse a String283
250String(represents an integer) to value283
251Word Search Leetcode Solution281
252Reverse Bits281
253Delete a node under given conditions280
254Print all Possible Ways to Break a String in Bracket Form280
255Binary Tree278
256Change Gender of a given String278
257How to Efficiently Implement k Stacks in a Single Array?276
258Sort an array of strings275
259First non Repeating Element274
260Count Pairs With Given Sum273
261Meeting Rooms II LeetCode Solution271
262Longest Common Extension271
263Number of sub-strings which recursively add up to 9271
264Remove middle points in a linked list of line segments270
265Toeplitz Matrix270
266Repeated Substring Pattern269
267Move all negative elements to one side of array269
268N queen problem268
269Longest Palindromic Substring LeetCode Solution266
270Remove spaces from a string266
271Shuffle a given Array264
272Min Stack262
273Number of Islands LeetCode Solution260
274Cuckoo sequence program259
275Dijkstra Algorithm257
276House Robber Leetcode Solution256
277Max stack256
278Find, second, frequent, character255
279Most Frequent Element in an Array254
280Minimize the maximum difference between the heights254
281Clone a linked list with next and random pointer (Hashing)252
282Search Insert Position Leetcode Solution251
283Fibonacci numbers250
284Expression Evaluation250
285Sort linked which is sorted on absolute values249
286Sudoku Solver247
287Subset Leetcode247
288Valid Palindrome Leetcode Solution247
289Plus One Leetcode Solution247
290KMP Algorithm246
291Number Of 1 bits246
292Combination Sum Leetcode Solution245
293Word Search245
294How to Delete a Linked List244
295Evaluation of Postfix Expression244
296Reverse words in a string244
297Min Stack Leetcode Solution243
298Backspace String Compare239
299Set Matrix Zeroes237
300Sqrt(x) Leetcode Solution236
301Merge Sorted Arrays Leetcode Solution236
302Reversing a Queue235
303Pair of Positive Negative Values in an Array234
304Rabin Karp Algorithm234
305Common elements in all rows of a given matrix233
306Subarray with 0 sum233
307Tower Of Hanoi231
308Delete middle element of a stack230
309Contains Duplicate II Leetcode Solution230
310Product of array except self229
311Combination Sum228
312Intersection of Two Arrays II Leetcode Solution228
313Integer to Roman Leetcode Solution228
314String Compression228
315Pascal Triangle Leetcode227
316Reverse individual words225
317Count subarrays with equal number of 1’s and 0’s225
318Count of index pairs with equal elements in an array224
319Bellman Ford Algorithm224
320Implementation of Deque using Doubly Linked List224
321Minimum swaps required to bring all elements less than or equal to k together224
322Sliding Window Technique223
323Find Top K (or Most Frequent) Numbers in a Stream223
324Single Number Leetcode Solution223
325Add Binary Leetcode Solution222
326Construct Binary Tree from Given Inorder and Preorder Traversals222
327Arithmetic Expression Evaluation221
328Minimum Value to Get Positive Step by Step Sum Leetcode Solution221
329Segregate even and odd numbers220
330Contains Duplicate220
331Sort elements by frequency220
332Pow(x, n) Leetcode Solution219
333Page Replacement Algorithms in Operating Systems219
334Palindrome Linked List Leetcode Solution219
335Second Most Repeated Word in a Sequence219
336Postfix to Infix Conversion218
337Find sum of non-repeating elements (distinct) elements in an array218
338Count Odd Numbers in an Interval Range Leetcode Solution218
339Design a stack that supports getMin() in O(1) time and O(1) extra space217
340Maximum Number of Balloons Leetcode Solution217
341Group Words With Same Set of Characters217
342Next Permutation217
343Kruskal Algorithm216
344Smallest Subarray with k Distinct Numbers216
345Third Maximum Number Leetcode Solution215
346Convex Hull Algorithm214
347Scramble String214
348Find Lucky Integer in an Array Leetcode Solution213
349Sum of minimum and maximum elements of all subarrays of size k213
350Permutations Leetcode Solution213
351K-th Smallest Element in a Sorted Matrix213
352Longest Substring Without Repeating Characters LeetCode Solution213
353Top K Frequent Words213
354Find the Town Judge Leetcode Solution212
355Minimum operation to make all elements equal in array212
356Find Numbers with Even Number of Digits Leetcode Solution211
357Sorting array using Stacks211
358Longest Common Prefix Leetcode Solution211
359Maximum Subarray211
360Evaluate Division210
361Majority Element Leetcode Solution210
362First element occurring k times in an array209
363Count subarrays having total distinct elements same as original array209
364Special Number209
365Number of Good Pairs Leetcode Solution208
366Given two unsorted arrays find all pairs whose sum is x208
367Spiral Matrix LeetCode Solution208
368Minimum Path Sum207
369Swap Nodes in Pairs Leetcode Solutions207
370Prefix to Infix Conversion207
371Huffman Coding207
372Missing Number Leetcode Solution206
373Reverse a Number Using Stack206
374Pascal’s Triangle II Leetcode Solution206
375Check if two arrays are equal or not206
376Reversing the First K elements of a Queue205
377Search in Rotated Sorted Array Leetcode Solution205
378Count Primes Leetcode Solutions205
379Merge Two Sorted Lists Leetcode Solutions205
380Best Time to Buy and Sell Stock  II Leetcode Solution205
381Single Number204
382Sort Array by Increasing Frequency Leetcode Solution204
383Maximal Square204
384Minimum Absolute Difference Leetcode Solution204
385Minimum Steps to reach target by a Knight204
386Find duplicates in a given array when elements are not limited to a range204
387Group Anagrams203
388Power of Two Leetcode Solution203
389House Robber II Leetcode Solution202
390Find All Numbers Disappeared in an Array Leetcode Solution202
391Matrix Diagonal Sum Leetcode Solution202
392Top K Frequent Elements202
393Sorting using trivial hash function201
394Unique Paths Leetcode Solution201
395Fizz Buzz Leetcode201
396Running Sum of 1d Array Leetcode Solution201
397Expression Contains Redundant Bracket or Not201
398Maximum Distance Between two Occurrences of Same Element in Array201
399Maximum possible difference of two subsets of an array201
400Convert String To Int201
401Zigzag Conversion200
402Unique Paths200
403Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution200
404Find Minimum In Rotated Sorted Array200
405How to Implement Stack Using Priority Queue or Heap?200
406Subarray Sum Equals k199
407Range Sum Query 2D – Immutable Leetcode Solution199
408Max Consecutive Ones Leetcode Solution199
409How Many Numbers Are Smaller Than the Current Number Leetcode Solution199
410Find the first repeating element in an array of integers199
411Find Number of Employees Under every Employee198
412Find the Closest Palindrome number198
413Happy Number Leetcode Solution198
414Smallest Element Repeated Exactly K Times198
415Leetcode Permutations198
416Sort Integers by The Number of 1 Bit Leetcode Solution198
417Check if Array Contains Contiguous Integers With Duplicates Allowed198
418Coin Change 2 Leetcode Solution198
419Difference between highest and least frequencies in an array197
420Subset sum problem197
421Subarray Sum Equals K LeetCode Solution197
422Palindrome Substring Queries197
423Decode String197
424Letter Case Permutation197
425Find Winner on a Tic Tac Toe Game Leetcode Solution197
426Cumulative Frequency of Count of Each Element in an Unsorted Array197
427Length of the largest subarray with contiguous elements196
428Monotonic Array LeetCode Solution196
429Best Time to Buy and Sell Stock III Leetcode Solution196
430Reverse Integer196
431Print All Distinct Elements of a Given Integer Array196
432Remove Duplicates from Sorted Array Leetcode Solution196
433Sort a stack using recursion195
434Implement Stack and Queue using Deque195
435Find top three repeated in array195
436Fibonacci Number LeetCode Solution194
437Generate a String With Characters That Have Odd Counts Leetcode Solution194
438Count Substrings with equal number of 0s, 1s and 2s194
439Nth Catalan Number194
440Capacity To Ship Packages Within D Days Leetcode Solution194
441Reverse Vowels of a String Leetcode Solution194
442Subtract the Product and Sum of Digits of an Integer Leetcode Solution193
443Reverse a Stack Using Recursion193
444Find Median from data Stream193
445Print all subarrays with 0 sum193
446Sum of Subarray Ranges Leetcode Solution193
447Find The Duplicate Number193
448Reverse Words in a String III LeetCode Solution193
449LRU Cache Implementation193
450Maximum Depth of Binary Tree Leetcode Solution193
451Shuffle the Array Leetcode Solution192
452Bipartite Graph192
453Check If N and Its Double Exist Leetcode Solution192
454Prim’s Algorithm192
455Delete a Node from linked list without head pointer192
456Trapping Rain Water Leetcode Solution192
457Integer to English words192
458Subarrays with distinct elements192
459Find the Duplicate Element191
460Merge Two Sorted Linked Lists191
461Longest Common Subsequence190
462Kth largest element in an Array Leetcode Solutions190
463Sorting a Queue without Extra Space190
464Iterative Tower of Hanoi190
465Find Common Characters Leetcode Solution190
466Excel Sheet Column Number Leetcode Solution190
467Target Sum190
468Priority Queue Using Singly Linked List190
469Reverse a String190
470Find the Difference Leetcode Solution190
471Balanced Binary Tree Leetcode Solution189
472Concatenation of Array LeetCode Solution189
473Find all pairs (a, b) in an array such that a % b = k189
474Edit Distance189
475Count and Say189
476Fizz Buzz189
477Remove Minimum Number of Elements Such That no Common Element Exist in both Array188
478Minimum Moves to Equal Array Elements Leetcode Solution188
479Count pairs from two linked lists whose sum is equal to a given value188
480Kids With the Greatest Number of Candies Leetcode Solution188
481Longest Common Prefix using Trie187
482Next Greater Element I Leetcode Solution187
483Word Ladder LeetCode Solution187
484Find elements which are present in first array and not in second187
485Kth Largest Element in a Stream Leetcode Solution187
486Number of Steps to Reduce a Number to Zero Leetcode Solution187
487The K Weakest Rows in a Matrix Leetcode Solution187
488Reverse a linked list187
489Floyd Warshall Algorithm187
490Find First and Last Position of Element in Sorted Array Leetcode Solution187
491Degree of an array187
492Text Justification LeetCode Solution186
493Merge Overlapping Intervals186
494Find subarray with given sum (Handles Negative Numbers)186
495Shortest Palindrome186
496Design Parking System Leetcode Solution186
497Flood Fill LeetCode185
498Find four elements that sum to a given value (Hashmap)185
499MiniMax Algorithm185
500Zigzag Conversion LeetCode Solution185
501Count and Say Leetcode Solution185
502Multiply Strings Leetcode Solution185
503Prefix to Postfix Conversion185
504Slowest Key Leetcode Solution185
505Valid Parenthesis String184
506Top View of Binary Tree184
507Jump Game Leetcode Solution184
508Move Zeroes LeetCode Solution184
509Priority Queue in C++184
510Find N Unique Integers Sum up to Zero Leetcode Solution184
511Longest subarray not having more than K distinct elements184
512Max Area of Island184
513Convert array into Zig-Zag fashion183
514Next Greater Frequency Element183
515The Stock Span Problem183
516Recursion183
517Substring With Concatenation Of All Words183
518Mobile Numeric Keypad Problem183
519Pair with given product183
520Find any one of the multiple repeating elements in read only array183
521Find distinct elements common to all rows of a matrix183
522Peak Index in a Mountain Array183
523Length of Last Word Leetcode Solution183
524Shuffle String Leetcode Solution182
525Check if a given array contains duplicate elements within k distance from each other182
526Implement a stack using single queue182
527Iterative Inorder Traversal of a Binary Tree182
528Count number of triplets with product equal to given number182
529Intersection of Two Arrays182
530Longest Common Prefix using Sorting182
531Relative Sort Array Leetcode Solution181
532Excel Sheet Column Title Leetcode Solution181
533Find Index of Closing Bracket for a Given Opening Bracket in an Expression181
534Largest Sum Contiguous Subarray181
535Delete Node in a Linked List Leetcode Solution181
536Find missing elements of a range181
537Last Stone Weight181
538Postfix to Prefix Conversion181
539Implement Stack using Queues180
540Koko Eating Bananas Leetcode Solution180
541Smallest Subarray With all Occurrences of a Most Frequent Element180
542Contiguous Array Leetcode180
543Is Subsequence Leetcode Solution179
544Convert a normal BST to Balanced BST179
545N-th Tribonacci Number Leetcode Solution179
546Best Time to Buy and Sell Stock178
547Container with Most Water178
548Implementation of Deque using circular array178
549Rearrange a binary string as alternate x and y occurrences178
550Jewels and Stones Leetcode Solution178
551Isomorphic Strings Leetcode Solution178
552K-th Distinct Element in an Array178
553Minimum Bracket Reversals178
554Change the Array into Permutation of Numbers From 1 to N178
555Valid Sudoku178
556Linked List Cycle II LeetCode Solution178
557Group Multiple Occurrence of Array Elements Ordered by first Occurrence178
558Distribute Candies to People Leetcode Solution178
559Unique Binary Search Trees177
560Build Array From Permutation Leetcode Solution177
561Integer to Roman177
562Find Words That Can Be Formed by Characters Leetcode Solution177
563Gold Mine Problem177
564Largest Perimeter Triangle Leetcode Solution177
565Valid Anagrams177
566Check for Balanced Parentheses in an Expression177
567Assign Cookies Leetcode Solution177
568Sum of Left Leaves Leetcode Solutions177
569Minimum Operations to convert X to Y177
570Convert Sorted Array to Binary Search Tree Leetcode Solution177
571First negative integer in every window of size k177
572Hamming Distance176
573Arrange given numbers to form the biggest number176
574Shuffle an Array176
57501 Matrix LeetCode Solution176
576Combinations Leetcode Solution176
577Remove Linked List Elements Leetcode Solution176
578Island Perimeter Leetcode Solution176
579Minimum Knight Moves LeetCode Solution176
580Rotate List Leetcode Solution175
581Summary Ranges Leetcode Solution175
582Minimum Delete Operations to make all Elements of Array Same175
583Count all subsequences having product less than K175
584The Knapsack Problem175
585Trapping Rain Water LeetCode Solution175
586Count the number of nodes at given level in a tree using BFS174
587Maximum sum rectangle in a 2D matrix174
588LRU Cache LeetCode Solution174
589Decode Ways174
590Distance Between Bus Stops Leetcode Solution173
591Maximum Distance in Array173
592Find the smallest positive integer value that cannot be represented as sum of any subset of a given array173
593Maximum path sum in a triangle173
594Insert Interval Leetcode Solution173
595Maximum Number of Chocolates to be Distributed Equally Among k Students173
5963Sum Closest LeetCode Solution173
597Shortest Path in a Grid with Obstacles Elimination LeetCode Solution173
598Minimum number of distinct elements after removing m items172
599Same Tree LeetCode Solution171
600Minimum insertions to form a palindrome with permutations allowed171
601Permutation in String Leetcode Solution171
602Replace Elements with Greatest Element on Right Side Leetcode Solution171
603Stone Game LeetCode171
604How to check if two given sets are disjoint?171
605Sieve of Eratosthenes171
606Rotate Image LeetCode Solution171
607Sort Characters By Frequency LeetCode Solution171
608Find minimum difference between any two elements171
609Minimum number of subsets with distinct elements171
610Find if an Expression has Duplicate Parenthesis or Not170
611Reverse a stack without using extra space in O(n)170
612Painting Fence Algorithm170
613Bubble sort using two Stacks170
614Frog Jump Leetcode Solution170
615Remove All Occurrences of a Substring LeetCode Solution170
616K Empty Slots LeetCode170
617Word Pattern170
618Sort Array By Parity LeetCode Solution170
619XOR Operation in an Array Leetcode Solution170
620Smallest Good Base170
621Word Wrap Problem170
622Applications of Breadth First Search and Depth First Search170
623Tracking current Maximum Element in a Stack169
624House Robber169
625Printing brackets in Matrix Chain Multiplication Problem169
626Defanging an IP Address Leetcode Solution169
627Distance of nearest cell having 1 in a binary matrix169
628Minimum Depth of Binary Tree Leetcode Solution169
629Best Time to Buy and Sell Stock LeetCode Solution169
630Maximum Consecutive Numbers Present in an Array169
631Non-overlapping sum of two sets169
632Isomorphic Strings169
633Longest Substring with At Most K Distinct Characters LeetCode Solution168
634Wiggle Sort168
635Segregate 0s and 1s in an Array168
636Minimum Cost to Hire K Workers168
637Find Sum of all unique sub-array sum for a given array168
638Longest Increasing Subsequence168
639Find the Duplicate Number LeetCode Solution168
640License Key Formatting Leetcode Solution168
641How to Create Mergable Stack?167
642Count Good Nodes in Binary Tree Leetcode Solution167
643Valid Palindrome II Leetcode Solution167
644Sum of All Odd Length Subarrays Leetcode Solution167
645Find Maximum Level sum in Binary Tree167
646Binary Tree Zigzag Level Order Traversal LeetCode Solution167
647Optimal Account Balancing LeetCode Solution167
648Iterative Method to find Height of Binary Tree167
649Coin Change Problem167
650Maximum difference between first and last indexes of an element in array167
651Moving Average from Data Stream Leetcode Solution167
652Strobogrammatic Number LeetCode Solution166
653GCD Of Two Numbers166
654Kth Missing Positive Number Leetcode Solution166
655Maximum Number of Occurrences of a Substring Leetcode Solution166
656Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions166
657Queries for counts of array elements with values in given range166
658Employee Free Time LeetCode Solution166
659Check If It Is a Straight Line Leetcode Solution166
660Merge Two Balanced Binary Search Trees166
661Best Time to Buy and Sell Stock with Cooldown Leetcode Solution166
662Find the Distance Value Between Two Arrays Leetcode Solution165
663Number of Provinces Leetcode Solution165
664Reorganize String165
665Path With Maximum Minimum Value LeetCode Solution165
666Valid Palindrome165
667Letter Combinations of a Phone Number165
668Flipping an Image LeetCode Solution165
669Longest Substring with At Least K Repeating Characters LeetCode Solution165
670Convert an array to reduced form165
671Find Largest d in Array such that a + b + c = d165
672Partition Labels LeetCode Solution164
673Find pairs with given sum such that elements of pair are in different rows164
674Maximum Number of Coins You Can Get Leetcode Solution164
675Delete consecutive same words in a sequence164
676Valid Perfect Square Leetcode Solution163
677Edit Distance LeetCode Solution163
678Populating Next Right Pointers in Each Node163
679Recover Binary Search Tree163
680Longest Increasing Path in a Matrix LeetCode Solution163
681K Empty Slots163
682Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest163
683Number of Dice Rolls With Target Sum LeetCode Solution163
684To Lower Case Leetcode Solution163
685Power of Four Leetcode Solution163
686Partition Array Into Three Parts With Equal Sum Leetcode Solution163
687Factorial Trailing Zeroes Leetcode Solution163
688Inorder Successor of a node in Binary Tree163
689Permutation Sequence LeetCode Solution163
690Print the Fibonacci numbers in reverse order163
691Reducing Dishes LeetCode Solution163
692Check If Two String Arrays are Equivalent Leetcode Solution163
693Merge Two Binary Trees LeetCode Solution162
694Construct BST from given Preorder Traversal162
695Lucky Numbers in a Matrix Leetcode Solution162
696Form minimum number from given sequence162
697Sort Array by Increasing Frequency Leetcode Solution162
698Dynamic Programming Basics162
699Increasing Decreasing String Leetcode Solution162
700Check if a queue can be sorted into another queue using a stack162
701Remove Invalid Parentheses Leetcode Solution162
702Maximum Product of Two Elements in an Array Leetcode Solution162
703String to Integer (atoi) LeetCode Solution162
704BFS vs DFS for Binary Tree162
705Convert a Number to Hexadecimal Leetcode Solution161
706Find whether an array is subset of another array161
707Ugly Number Leetcode Solution161
708Unique Paths II Leetcode Solution161
709Subset Sum Leetcode161
710Binary Tree zigzag level order Traversal161
711Reverse Only Letters LeetCode Solution161
712Robot Room Cleaner Leetcode Solution161
713Find the Smallest Divisor given a Threshold Leetcode Solution161
714Reversing a Queue using Recursion161
715Reservoir Sampling161
716Delete Nth node from the end of the given linked list160
717Restore IP Addresses Leetcode Solution160
718Find Leaves of Binary Tree LeetCode Solution160
719Keyboard Row Leetcode Solution160
720Majority Element II Leetcode Solution160
721Binomial Coefficient160
722Check if Two Expressions With Brackets are Same159
723Perform String Shifts Leetcode159
724Decompress Run-Length Encoded List Leetcode Solution159
725Bulb Switcher LeetCode Solution159
726Find the node with minimum value in a Binary Search Tree159
727Find the largest multiple of 3159
728Numbers with prime frequencies greater than or equal to k159
729Add and Search Word – Data structure design LeetCode159
730Finding K closest element158
731Race Car LeetCode Solution158
732Maximum Product of Three Numbers LeetCode Solution158
733Sum of f(a[i], a[j]) over all pairs in an array of n integers158
734Generate all possible sorted arrays from alternate elements of two given sorted arrays158
735Number of Islands II LeetCode Solution158
736Maximum 69 Number Leetcode Solution158
737Find Pair with Greatest Product in Array158
738Minimum Cost For Tickets Leetcode Solution158
739Morris Traversal158
740Hamming Distance Leetcode Solution158
741Sorted Linked List to Balanced BST157
742Merge K Sorted Linked Lists157
743Maximum Depth of N-ary Tree Leetcode Solution157
744Student Attendance Record I Leetcode Solution157
745First Unique Character in a String LeetCode Solution157
746String Compression LeetCode Solution157
747Invert Binary Tree LeetCode Solution157
748Minimum Distance Between BST Nodes Leetcode Solution157
749Tiling Problem157
750Word Pattern LeetCode Solution157
751Rank Transform of an Array Leetcode Solution157
752Find Maximum Depth of Nested Parenthesis in a String157
753Minimum Height Trees157
754Diagonal Traversal of Binary Tree157
755Check If Array Pairs Are Divisible by k LeetCode Solution156
756Find unique character in a string156
757Queue based approach for first non-repeating character in a stream156
758Binary Tree Maximum Path Sum LeetCode Solution156
759Special Array With X Elements Greater Than or Equal X Leetcode Solution156
760Best Meeting Point LeetCode Solution156
761Minimum time required to rot all oranges156
762Kth ancestor of a node in binary tree156
763Find All Duplicates in an Array LeetCode Solution156
764Remove brackets from an algebraic string containing + and – operators156
765Longest Span with same Sum in two Binary arrays156
766Snakes and Ladders LeetCode Solution156
767Find if Path Exists in Graph Leetcode Solution156
768Non-decreasing Array LeetCode Solution156
769Symmetric Tree Leetcode Solution156
770Largest subarray with equal number of 0s and 1s156
771Remove Nth Node From End of List Leetcode Solution156
772Final Prices With a Special Discount in a Shop Leetcode Solution155
773Search a 2D Matrix II Leetcode Solution155
774Evaluate Reverse Polish Notation LeetCode Solution155
775Largest Rectangle in Histogram LeetCode Solution155
776Elements to be added so that all elements of a range are present in array155
777Find Median from Data Stream LeetCode Solution155
778Stack Permutations (Check if an array is stack permutation of other)155
779Maximum Length of a Concatenated String with Unique Characters Leetcode Solution155
780Largest rectangular sub-matrix whose sum is 0155
781Minimize Maximum Pair Sum in Array LeetCode Solution155
782Partition to K Equal Sum Subsets Leetcode Solution155
783Jump Game155
784Count items common to both the lists but with different prices154
785Valid Number154
786Maximum Difference Between Increasing Elements LeetCode Solution154
787Split a String in Balanced Strings Leetcode Solution154
788Transpose Graph154
789Program for Bridge and Torch problem154
790Total Numbers With no Repeated Digits in a Range154
791k-th missing element in increasing sequence which is not present in a given sequence154
792Linked List Cycle154
793N-Queens LeetCode Solution153
794One Edit Distance LeetCode Solution153
795Growable array based stack153
796Nearest Exit from Entrance in Maze LeetCode Solution153
797Check for Palindrome after every character replacement Query153
798Search in a Binary Search Tree Leetcode Solution153
799Get Maximum in Generated Array Leetcode Solution153
800Deletion in a Binary Tree153
801Count quadruples from four sorted arrays whose sum is equal to a given value x153
802Print a Binary Tree in Vertical Order153
803Number of NGEs to the Right153
804Base 7 Leetcode Solution153
805Sort an array according to the order defined by another array153
806Interval Tree153
807Minimum Jumps to Reach Home LeetCode Solution153
808Last Stone Weight II LeetCode Solution153
809Remove Duplicates from Sorted List II152
810Minimum swaps to make sequences increasing152
811Minimum number of jumps to reach end152
812Iterative Preorder Traversal152
813Relative Ranks Leetcode Solution152
814A Space Optimized DP solution for 0-1 Knapsack Problem152
815Subarray Product Less Than K LeetCode Solution152
816Circular Queue152
817Course Schedule II – LeetCode152
818Minimum Time Visiting All Points Leetcode Solution152
819Nested List Weight Sum II LeetCode Solution152
820String comparison containing wildcards152
821Priority Queue using doubly linked list152
822Remove Duplicates from Sorted List LeetCode Solution152
823Crawler Log Folder Leetcode Solution152
824Reorder Data in Log Files LeetCode Solution152
825Maximum Profit in Job Scheduling Leetcode Solution152
826Number Complement Leetcode Solution152
827Merge Sorted Array LeetCode Solution152
828Find all triplets with zero sum151
829Sort Array By Parity II Leetcode Solution151
830Maximum size subarray sum equals k151
831Spiral Matrix II Leetcode Solution151
832Form Minimum Number From Given Sequence151
833Longest Subarray Having Count of 1s One More than Count of 0s151
834Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution150
835Brick Wall LeetCode Solution150
836Find the subarray with least average150
837Path with maximum average value150
838Minimum Number of Taps to Open to Water a Garden LeetCode Solution150
839Valid Parentheses Leetcode Solution150
840Convert BST to Min Heap150
841Alien Dictionary LeetCode Solution150
842Insert into a Binary Search Tree Leetcode Solution150
843Regular Expression Matching150
844Given an Array of Pairs Find all Symmetric Pairs in it150
845Can Place Flowers LeetCode Solution150
846Sum of nearest smaller and greater number150
847Maximum Nesting Depth of the Parentheses Leetcode Solution150
848Partition List Leetcode Solution149
849Subset with sum divisible by m149
850Check whether a given Binary Tree is Complete or not149
851Count Negative Numbers in a Sorted Matrix LeetCode Solution149
852Clone Graph LeetCode Solution149
853Binary Search Tree Search and Insertion149
854Sort Colors149
855Top K Frequent Words LeetCode Solution149
856Permutation Coefficient149
857Minimum Sum Path in a Triangle149
858Check if a given array can represent Preorder Traversal of Binary Search Tree149
859Find All Possible Recipes from Given Supplies LeetCode Solution149
860Level order Traversal in Spiral Form149
861Count Distinct Elements in Every Window of Size K149
862Friends Pairing Problem149
863Subsequence of Size K With the Largest Even Sum LeetCode Solution149
864Tree Traversal (Preorder, Inorder & Postorder)148
865Find the Only Repetitive Element Between 1 to N-1148
866An Interesting Method to generate Binary Numbers from 1 to n148
867Design a Stack With Increment Operation Leetcode Solution148
868Guess Number Higher or Lower LeetCode Solution148
869Find Maximum Sum Possible Equal Sum of Three Stacks148
870Range LCM Queries148
871Brightest Position on Street LeetCode Solution148
872Missing Element in Sorted Array LeetCode Solution148
873Matrix Chain Multiplication148
874LCS (Longest Common Subsequence) of three strings148
875Check if stack elements are pairwise consecutive148
876Sequences of given length where every element is more than or equal to twice of previous148
877Distinct adjacent elements in an array147
878Design Browser History LeetCode Solution147
879Diagonal Traversal LeetCode Solution147
880Water Bottles Leetcode Solution147
881Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution147
882Convert Sorted List to Binary Search Tree147
883Identify and Mark Unmatched Parenthesis in an Expression147
884Repeated Substring Pattern LeetCode Solution147
885Balanced Expression with Replacement147
886Sorted Array to Balanced BST147
887K’th Largest Element in BST when modification to BST is not allowed147
888Number of Days Between Two Dates LeetCode Solution147
889Diagonal Traverse LeetCode Solution147
890Union and Intersection of two Linked Lists146
891GCDs of given index ranges in an array146
892Three way partitioning of an array around a given range146
893Guess Number Higher or Lower II146
894Special Positions in a Binary Matrix Leetcode Solution146
895Daily Temperatures Leetcode Solution146
896Minimum sum of multiplications of n numbers146
897Check if an Array is Stack Sortable146
898Shortest Word Distance Leetcode Solution146
899Rearrange an Array Such that arr[i] is equal to i146
900BFS for Disconnected Graph146
901Destination City Leetcode Solution146
902Maximum Score After Splitting a String Leetcode Solution146
903Time Based Key-Value Store LeetCode Solution146
904Insert Delete GetRandom146
905Least Number of Unique Integers after K Removals Leetcode Solution145
906Check if the given array can represent Level Order Traversal of Binary Search Tree145
907Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i145
908Range sum queries without updates145
909Queue using Stacks145
910Count ways to reach the nth stair using step 1, 2 or 3145
911Robot Bounded In Circle LeetCode Solution145
912Minimum Swaps to Make Strings Equal Leetcode Solution145
913Find Common Characters Leetcode Solution145
914Spiral Matrix III LeetCode Solution145
915Lemonade Change Leetcode Solution145
916Delete And Earn145
917Find distance between two nodes of a Binary Tree145
918Number of Distinct Islands Leetcode Solution144
919Rearrange Spaces Between Words Leetcode Solution144
920Construct BST from its given Level Order Traversal144
921Vertical sum in a given binary tree144
922Print Fibonacci sequence using 2 variables144
9234Sum144
924Palindrome Partitioning Leetcode Solution144
925Merge Two Sorted Lists Leetcode144
926Construct Complete Binary Tree from its Linked List Representation144
927A program to check if a binary tree is BST or not143
928Maximum Frequency Stack Leetcode Solution143
929Check if any two intervals overlap among a given set of intervals143
930Minimum Height Trees LeetCode Solution143
931Alien Dictionary143
932Maximum Subarray Sum Excluding Certain Elements143
933Split Array Into Consecutive Subsequences143
934Construct the Rectangle Leetcode Solution143
935Stone Game II Leetcode143
936Averages of Levels in Binary Tree143
9373 Sum143
938Set Matrix Zeroes Leetcode Solution143
939Difference Array | Range update query in O(1)143
940Queries for GCD of all numbers of an array except elements in a given range142
941Analyze User Website Visit Pattern LeetCode Solution142
942Remove Duplicates from Sorted List II LeetCode Solution142
943Strongly Connected Component142
944Binary Tree Longest Consecutive Sequence LeetCode Solution142
945Count Subarrays with Same Even and Odd Elements142
946Infix to Postfix142
947Trim a Binary Search Tree142
948Create Maximum Number142
949Lexicographical Numbers Leetcode Solution142
950Iterative Postorder Traversal Using Two Stacks142
951Longest Palindromic Subsequence142
952Largest area rectangular sub-matrix with equal number of 1’s and 0’s142
953Binary array after M range toggle operations141
954Sliding Window Maximum141
955All Unique Triplets that Sum up to a Given Value141
956Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space141
957Unique Paths II141
958Count Submatrices With All Ones LeetCode Solution141
959Collect maximum points in a grid using two traversals141
960Number of Equivalent Domino Pairs Leetcode Solution141
961Find all permuted rows of a given row in a matrix141
962Minesweeper LeetCode Solution140
963Intersection of Two Linked Lists LeetCode Solution140
964Reverse Nodes in K-Group140
965Find postorder traversal of BST from preorder traversal140
966Sign of the Product of an Array LeetCode Solution140
967Three Consecutive Odds Leetcode Solution140
968Can Make Arithmetic Progression From Sequence Leetcode Solution140
969Dividing Array into Pairs With Sum Divisible by K140
970Merging Intervals140
971Height of a generic tree from parent array140
972Maximum Product Subarray140
973Count subarrays where second highest lie before highest140
974Pattern Occurrences using Stack140
975Word Break140
976Symmetric Tree139
977Length of Longest Fibonacci Subsequence139
978Kth Smallest Element in a BST Leetcode Solution139
979Count pair with Given Sum139
980Find the Difference Leetcode Solution139
981Median of Two Sorted Arrays139
982Newman-Conway Sequence139
983Binary Search Tree Delete Operation139
984Count Primes in Ranges139
985Level Order Traversal of Binary Tree139
986Palindrome Partitioning139
987The Painter’s Partition Problem139
988Product of Array Except Self LeetCode Solution139
989Longest Nice Substring LeetCode Solution139
990Maximize Sum of Array after K Negations Leetcode Solution138
991K Closest Points to Origin Leetcode Solution138
992Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution138
993Find Maximum of Minimum for Every Window Size in a Given Array138
994Climbing stairs138
995My Calendar I LeetCode Solution138
996Segment Tree138
997Asteroid Collision LeetCode Solution138
998Boundary Traversal of binary tree137
999Find the First Circular Tour that visits all the Petrol Pumps137
1000Valid Boomerang Leetcode Solution137
1001Number of palindromic paths in a matrix137
1002Maximum subsequence sum such that no three are consecutive137
1003Find Duplicate Subtrees137
1004String Matching in an Array Leetcode Solution137
1005Maximum Product of Indexes of Next Greater on Left and Right137
1006Breadth First Search (BFS) for a Graph137
1007Depth First Search (DFS) for a Graph137
1008Merge Sort137
1009Number Of Longest Increasing Subsequence137
1010Maximum Length of Repeated Subarray137
1011Construction of Longest Increasing Subsequence (N log N)137
1012Largest Number Leetcode Solution137
1013Largest divisible pairs subset137
1014Friends Of Appropriate Ages LeetCode Solution137
1015Double the first element and move zero to end137
1016Compute nCr % p137
1017The Maze III LeetCode Solution137
1018Find number of pairs in an array such that their XOR is 0137
1019Shortest Completing Word Leetcode Solution137
1020Make The String Great Leetcode Solution136
1021Morris Inorder Traversal136
1022First missing positive136
1023Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’136
1024Level order traversal using two Queues136
1025Construct Binary Tree from given Parent Array representation136
1026Graph Valid Tree LeetCode Solution136
1027Insertion in a Binary Tree136
1028Minimum Index Sum of Two Lists136
1029Next Greater Element III LeetCode Solution136
1030Kill Process LeetCode Solution136
1031Largest Substring Between Two Equal Characters Leetcode Solution136
1032Serialize and Deserialize Binary Tree136
1033Binary Search Tree136
1034Maximum Number of Ways to Partition an Array LeetCode Solution136
1035Boolean Parenthesization Problem136
1036Maximum weight transformation of a given string136
1037Scramble String LeetCode Solution136
1038Partition Equal Subset Sum136
1039K maximum sums of overlapping contiguous sub-arrays135
1040Decrypt String from Alphabet to Integer Mapping Leetcode Solution135
1041Invalid Transactions LeetCode Solution135
1042Build an Array With Stack Operations Leetcode Solution135
1043Design Hit Counter LeetCode Solution135
1044Count minimum steps to get the given desired array135
1045Longest subsequence such that difference between adjacents is one135
1046Advantages of BST over Hash Table135
1047Path Sum II LeetCode Solution134
1048Custom Sort String Leetcode Solution134
1049Rearrange array such that even positioned are greater than odd134
1050Ugly Numbers134
1051Available Captures for Rook Leetcode Solution134
1052Maximum Sum of 3 Non-Overlapping Subarrays134
1053Balanced Binary Tree134
1054Validate Binary Search Tree134
1055Super Ugly Number133
1056Maximum difference between frequency of two elements such that element having greater frequency is also greater133
1057Count pairs from two sorted arrays whose sum is equal to a given value x133
1058Maximum length subsequence with difference between adjacent elements as either 0 or 1133
1059Iterative Depth First Traversal of Graph133
1060Ugly Number II LeetCode Solution133
1061Implement Trie (Prefix Tree) Leetcode Solution133
1062Add two numbers133
1063Kth Smallest Element in a Sorted Matrix LeetCode Solution133
1064Defanging an IP Address LeetCode Solution133
1065Employee Importance LeetCode Solution133
1066Bitwise AND of Numbers Range LeetCode Solution133
1067Search in Sorted Rotated Array132
1068Find Peak Element132
1069Regular Expression Matching Regular Expression Matching LeetCode Solution132
1070Generate Parentheses Leetcode Solution132
1071Remove Duplicates from Sorted Array II Leetcode Solution132
1072Recover Binary Search Tree Leetcode Solution132
1073Lowest Common Ancestor132
1074Move all negative elements to end in order with extra space allowed132
1075Populating Next Right Pointers in Each Node Leetcode Solution132
1076Root to Leaf path with target sum Leetcode Solutions131
1077Minimum Size Subarray Sum131
1078Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution131
1079Longest Bitonic Subsequence131
1080Subarrays with K Different Integers Leetcode Solution131
1081Largest BST Subtree LeetCode Solution131
1082Find a Peak Element II LeetCode Solution131
1083Number of Students Doing Homework at a Given Time Leetcode Solution131
1084Binary Tree Right Side View LeetCode Solution131
1085Number of Closed Islands Leetcode Solution130
1086Smallest Common Region Leetcode Solution130
1087Day of the Year Leetcode Solution130
1088Clone a Binary Tree with Random Pointers130
1089Rearrange array such that even index elements are smaller and odd index elements are greater130
1090Maximize Distance to Closest Person LeetCode Solution130
1091Find whether a subarray is in form of a mountain or not130
1092Number of siblings of a given Node in n-ary Tree130
1093Combination Sum IV LeetCode Solution130
1094Kth Smallest Product of Two Sorted Arrays LeetCode Solution130
1095Types of Binary Tree129
1096Palindrome Permutation LeetCode Solution129
1097Minimum Absolute Difference in BST Leetcode Solution129
1098Level of Each node in a Tree from source node129
1099Serialize and Deserialize Binary Tree LeetCode Solution129
1100Increasing Triplet Subsequence LeetCode Solution129
1101Count Largest Group Leetcode Solution129
1102Consecutive Characters LeetCode Solution129
1103Distinct Subsequences129
1104Remove Palindromic Subsequences Leetcode Solution129
1105Find Smallest Range Containing Elements from k Lists129
1106Next Permutation Leetcode Solution129
1107Find the minimum distance between two numbers129
1108Convert BST into a Min-Heap without using array129
1109Binary Tree Data Structure129
1110Find maximum difference between nearest left and right smaller elements129
1111Valid Tic-Tac-Toe State LeetCode Solution128
1112Find Three Element From Different Three Arrays Such That a + b + c = sum128
1113Constant time range add operation on an array128
1114Third Maximum Number Leetcode Solution128
1115Divisible Pairs Counting128
1116Cutting a Rod128
1117Iterative method to find ancestors of a given binary tree128
1118Path Sum128
1119Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution128
1120Print all triplets in sorted array that form AP128
1121Remove duplicates from sorted array128
1122Prime Palindrome LeetCode Solution127
1123Delete Nodes and Return Forest Leetcode Solution127
1124Products of ranges in an array127
1125Construct K Palindrome Strings LeetCode Solution127
1126Sum of Even Numbers After Queries127
1127Maximum Product Subarray127
1128Reformat The String Leetcode Solution127
1129Print Next Greater Number of Q queries127
1130Longest Subarray of 1’s After Deleting One Element LeetCode Solution127
1131Minimum Score Triangulation of Polygon Leetcode Solution126
1132Cells with Odd Values in a Matrix LeetCode Solution126
1133Write Code to Determine if Two Trees are Identical126
1134Longest Increasing Consecutive Subsequence126
1135Mean of Array After Removing Some Elements Leetcode Solution126
1136Search Insert Position126
1137Print Right View of a Binary Tree126
1138Bottom View of a Binary Tree126
1139Thousand Separator Leetcode Solution126
1140Palindromic Substrings Leetcode Solution125
1141Merge two BSTs with limited extra space125
1142Minimum sum of squares of character counts in a given string after removing k characters125
1143Search an Element in Sorted Rotated Array125
1144Moser-de Bruijn Sequence125
1145Topological Sorting125
1146Maximum Binary Tree124
1147Closest Binary Search Tree Value Leetcode Solution124
1148Red-Black Tree Introduction124
1149Swap Nodes In Pairs124
1150Subset Sum Problem in O(sum) space124
1151Find maximum length Snake sequence124
1152Priority Queue124
1153Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution124
1154Maximum Product of Splitted Binary Tree LeetCode Solution124
1155Diameter of N-Ary Tree LeetCode Solution123
1156Check Array Formation Through Concatenation Leetcode Solution123
1157Golomb sequence123
1158Bus Routes Leetcode Solution123
1159Print modified array after executing the commands of addition and subtraction123
1160Possible Bipartition LeetCode Solution123
1161Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution122
1162Web Crawler LeetCode Solution122
1163Transform a BST to Greater sum Tree122
1164Queries for Number of Distinct Elements in a Subarray122
1165Binary Tree to Binary Search Tree Conversion122
1166Rotate Array122
1167Search Suggestions System LeetCode Solution122
1168Find Largest Value in Each Tree Row LeetCode Solution122
1169Minimum Sideway Jumps LeetCode Solution122
1170Kth Smallest Number in Multiplication Table Leetcode Solution122
1171Find a sorted subsequence of size 3 in linear time122
1172Maximize sum of consecutive differences in a circular array122
1173Count even length binary sequences with same sum of first and second half bits122
1174Decision Tree121
1175Longest Repeated Subsequence121
1176Find the smallest binary digit multiple of given number121
1177Minimum Cost to Move Chips to The Same Position LeetCode Solution121
1178Matchsticks to Square Leetcode Solution121
1179Graph and its representation121
1180Compare Strings by Frequency of the Smallest Character Leetcode Solution121
1181Decrease Elements To Make Array Zigzag LeetCode Solution120
1182Contiguous Array LeetCode Solution120
1183Factorial Trailing Zeroes LeetCode Solution120
1184First Bad Version120
1185Convert Sorted Array to Binary Search Tree LeetCode Solutions120
1186Swapping Nodes in a Linked List Leetcode Solution120
1187Lowest Common Ancestor in Binary Search Tree120
1188Minimum Moves to Equal Array Elements LeetCode Solution119
1189Maximum sum bitonic subarray119
1190Valid Triangle Number119
1191K’th Largest element in BST using constant extra space119
1192Number of Orders in the Backlog Leetcode Solution119
1193Queue Reconstruction by Height119
1194Reverse a Path in BST using Queue119
1195Sum of Left Leaves LeetCode Solution119
1196Moving Stones Until Consecutive Leetcode Solution118
1197Closest Leaf in a Binary Tree LeetCode Solution118
1198Reformat Date LeetCode Solution118
1199Given a binary tree, how do you remove all the half nodes?118
1200Lowest Common Ancestor of a Binary Tree Leetcode Solution118
1201Maximum number of segments of lengths a, b and c118
1202Range Queries for Longest Correct Bracket Subsequence118
1203Count Pairs Whose Products Exist in Array118
1204How to print maximum number of A’s using given four keys118
1205Maximum sum of pairs with specific difference118
1206Champagne Tower LeetCode Solution117
1207Array Queries for multiply replacements and product117
1208Maximum Depth Of Binary Tree117
1209Kth Smallest Element in a BST117
1210Guess The Word117
1211Concatenation of Array LeetCode Solution116
1212Minimum Swaps To Make Sequences Increasing LeetCode Solution116
1213Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution116
1214Replace two consecutive equal values with one greater116
1215Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution116
1216Path Crossing Leetcode Solution116
1217Range Sum Query using Sparse Table115
1218Flatten 2D Vector LeetCode Solution115
1219Perfect Squares LeetCode Solution115
1220Write a function to get the intersection point of two Linked Lists115
1221Valid Perfect Square LeetCode Solution115
1222Arithmetic Slices II – Subsequence LeetCode Solution115
1223Integer Break LeetCode Solution115
1224The kth Factor of n Leetcode Solution114
1225Power of Two114
1226New 21 Game114
1227Maximum sum of a path in a Right Number Triangle114
1228Sliding Window Median Leetcode Solution114
1229Check Completeness of a Binary Tree LeetCode Solution114
1230Design Skiplist LeetCode Solution114
1231BST to a Tree with Sum of all Smaller Keys114
1232Divide Two Integers Leetcode Solution114
1233Mean of range in array114
1234Check if each internal node of a BST has exactly one child114
1235LRU Cache Leetcode Solution114
1236Longest Common Prefix Using Word by Word Matching113
1237Queries on Probability of Even or Odd Number in given Ranges113
1238Maximum Array from Two given Arrays Keeping Order Same113
1239Largest Plus Sign Leetcode Solution113
1240Print modified array after multiple array range increment operations113
1241Find Minimum in Rotated Sorted Array II LeetCode Solution113
1242Contiguous Array113
1243Bold Words in String LeetCode Solution113
1244Maximize Elements Using Another Array113
1245Check if all levels of two Binary Tree are anagrams or not113
1246Maximum Value at a Given Index in a Bounded Array LeetCode Solution113
1247Check for Identical BSTs without building the trees113
1248Find k-th smallest element in BST (Order Statistics in BST)112
1249Print n terms of Newman-Conway Sequence112
1250Parallel Courses II LeetCode Solution112
1251Print Ancestors of a Given Binary Tree Node Without Recursion112
1252Merge k Sorted Lists Leetcode Solution111
1253Maximum Product Subarray111
1254Find minimum number of merge operations to make an array palindrome111
1255Count Subsets Having Distinct Even Numbers111
1256Graph Cloning111
1257Symmetric Tree LeetCode Solution Leetcode Solution111
1258Missing Number110
1259Smallest Range II Leetcode Solution110
1260Check if two nodes are on the same path in a Tree110
1261Minimum Remove to Make Valid Parentheses LeetCode Solution110
1262Count and Toggle Queries on a Binary Array110
1263Verify Preorder Serialization of a Binary Tree109
1264Next greater element109
1265Number of elements less than or equal to a given number in a given subarray109
1266Check If a String Can Break Another String Leetcode Solution108
1267Minimum Time to Collect All Apples in a Tree LeetCode Solution108
1268Excel Sheet Column Title LeetCode Solution108
1269Image Overlap LeetCode Solution108
1270Orderly Queue LeetCode Solution107
1271Koko Eating Bananas LeetCode Solution107
1272Different Ways to Add Parentheses Leetcode Solution107
1273Min Cost Climbing Stairs LeetCode Solution107
1274Palindrome Partitioning107
1275Check if X can give change to every person in the Queue105
1276Longest Substring Without Repeating Characters Leetcode Solution105
1277Largest Submatrix With Rearrangements LeetCode Solution105
1278Newman–Shanks–Williams prime105
1279Peeking Iterator LeetCode Solution105
1280Check in binary array the number represented by a subarray is odd or even104
1281Merge Sorted Array103
1282Range Minimum Query (Square Root Decomposition and Sparse Table)103
1283Array Nesting Leetcode Solution102
1284Maximum Sum Increasing Subsequence101
1285Arranging Coins Leetcode Solution101
1286Encoded String With Shortest Length LeetCode Solution100
1287Maximum product of an increasing subsequence100
1288Find maximum average subarray of k length100
1289Queries for Decimal Values of Subarrays of a Binary Array99
1290Minimum Total Space Wasted With K Resizing Operations LeetCode Solution99
1291Number of indexes with equal elements in given range99
1292Convert to Base -2 LeetCode Solution98
1293Minimum Number of People to Teach LeetCode Solution98
1294Convert a BST to a Binary Tree such that sum of all greater keys is added to every key97
1295Random Pick Index LeetCode Solution97
1296Reach a Number LeetCode Solution97
1297Vertical Order Traversal of Binary Tree LeetCode Solution96
1298Find the Winner of the Circular Game LeetCode Solution96
1299Binary Tree to Binary Search Tree Conversion using STL set96
1300Check given array of size n can represent BST of n levels or not96
1301Continuous Subarray Sum LeetCode Solution96
1302Add Two Numbers II Leetcode Solution96
1303Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution95
1304Queries on XOR of greatest odd divisor of the range95
1305Jump Game IV LeetCode Solution95
1306Palindrome Number LeetCode Solution95
1307Insert Delete GetRandom O(1) Leetcode Solution94
1308Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution94
1309Design Underground System Leetcode Solution90
1310Print Maximum Length Chain of Pairs89
1311Detect Capital Leetcode Solution87
1312Design A Leaderboard Leetcode Solution86
1313Minimum Swaps to Group All 1’s Together Leetcode Solution83
1314Top K Frequent Elements LeetCode Solution83
1315Substring with Concatenation of All Words Leetcode Solution83
1316Binary Tree Inorder Traversal LeetCode Solution81
1317Count Sub Islands LeetCode Solution80
1318Minimum Path Sum Leetcode Solution80
1319Shifting Letters LeetCode Solution79
1320Longest Common Subsequence LeetCode Solution77
1321Odd Even Linked List Leetcode Solution77
1322Find the Town Judge LeetCode Solution76
1323Best Meeting Point LeetCode Solution76
1324Decode String Leetcode Solution76
1325Maximum Population Year LeetCode Solution75
1326Find the Town Judge LeetCode Solution75
1327Sum Root to Leaf Numbers LeetCode Solution72
1328Shortest Unsorted Continuous Subarray LeetCode Solution72
1329Maximum Population Year LeetCode Solution71
1330Rectangle Overlap LeetCode Solution71
1331Design Add and Search Words Data Structure LeetCode Solution70
1332Stone Game IV LeetCode Solution67
1333Flatten Binary Tree to Linked List LeetCode Solution67
1334Score of Parenthesis LeetCode Solution67
1335Range Sum Query 2D – Immutable LeetCode Solution66
1336Insert into a Sorted Circular Linked List LeetCode Solution66
1337Reveal Cards In Increasing Order Leetcode Solution63
1338Valid Triangle Number LeetCode Solution62
1339Is Graph Bipartite? LeetCode Solution62
1340Divide Chocolate LeetCode Solution55
1341Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution48
1342Reverse Integer Leetcode Solution46
1343Range Sum of BST LeetCode Solution45
1344Sort Colors LeetCode Solution42
1345Find K Closest Elements LeetCode Solution40
1346Maximum Side Length of a Square with Sum Less than or Equal to Threshold LeetCode Solution38
1347Excel Sheet Column Number LeetCode Solution37
1348Rotate String LeetCode Solution37
1349Maximum Size Subarray Sum Equals k Leetcode Solution20
1350H-Index Leetcode Solution20
1351High Five LeetCode Solution19
1352Monotonic Array Leetcode Solution12
1353Insert Delete GetRandom O(1) – Duplicates allowed LeetCode Solution10
1354Unique Binary Search Trees LeetCode Solution10
1355Valid Triangle Number LeetCode Solution8
1356Peak Index in a Mountain Array LeetCode Solution7
1357Swim in Rising Water LeetCode Solution6
1358Isomorphic Strings LeetCode Solution4
1359Camelcase Matching Leetcode Solution4
Translate »