Detect Capital Leetcode Solution

Difficulty Level Easy
Frequently asked in Amazon Google
StringViews 84

Problem Statement:

Detect Capital Leetcode Solution says that – Given a string, return true if the usage of capitals in it is right. The conditions for the right words are :

  1. All letters in this word are capitals, like "UK".
  2. All letters in this word are not capitals, like "going".
  3. Only the first letter in this word is capital, like "Mango".

 

Example:

Input:  word: “India”

Output: true

Input: word: “HaPpy”

Output: false

Explanation:

Detect Capital Leetcode SolutionPin

This satisfies condition number 1. All the letters are capitalized. So the output will be “TRUE”.

Detect Capital Leetcode SolutionPin

This satisfies condition number 2. All the letters are small. So the output will be “TRUE”.

Detect Capital Leetcode SolutionPin
This satisfies condition number 3. So the output will be “TRUE”.

Detect Capital Leetcode SolutionPin

 This doesn’t satisfy any of the conditions. So the output will be “False”.

 

Approach:

Idea:

First, take two variables to say, “capital” and “small” to store the count of the capital letters and the small letters which are present in the given string. Now iterate through the string and update the values accordingly, which means if a capital letter is found then increase the count of the “capital” variable otherwise increase the “small” variable.

Then check the first two conditions. If the length of the given string is equal to any of the variable “capital” or “small”, return true as all the letters of the word may be capital or may be small.

After that, check for the third given condition where first check if the first character of the string is a capital letter or not and the length of the remaining string is equal to the “small” variable or not. If both of them are true, return true.

Finally, if none of the above conditions returns true, then return false.

 

Code:

C++ code for Detect Capital Leetcode Solution :

class Solution {
public:
    bool detectCapitalUse(string word) {
        int capitals=0, smalls=0;
        for(int i=0;i<word.size();i++){
            if(word[i]>='A' && word[i]<='Z'){
                capitals++;
            }
            else{
                smalls++;
            }
        }
        if(capitals==word.size() || smalls==word.size()){
            return true;
        }
        else if(word[0]>='A' && word[0]<='Z' && smalls==word.size()-1){
            return true;
        }
        else{
            return false;
        }
    }
};

Java code for Detect Capital Leetcode Solution :

class Solution {
    public boolean detectCapitalUse(String word) {
        int capitals=0, smalls=0;
        for(int i=0;i<word.length();i++){
            if(word.charAt(i)>='A' && word.charAt(i)<='Z'){
                capitals++;
            }
            else{
                smalls++;
            }
        }
        if(capitals==word.length() || smalls==word.length()){
            return true;
        }
        else if(word.charAt(0)>='A' && word.charAt(0)<='Z' && smalls==word.length()-1){
            return true;
        }
        else{
            return false;
        }
    }
}

Complexity Analysis for Detect Capital Leetcoee Solution:

Time Complexity:

Time complexity will be O(N) because of iterating over the whole string.

Space Complexity:

Space complexity will be O(1) as no extra space is used.

Reference: https://www.tutorialcup.com/python/python-string.htm

Top Interview Questions

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