Excel Sheet Column Number LeetCode Solution

Difficulty Level Easy
Frequently asked in Adobe Amazon Apple Bloomberg Facebook Goldman Sachs Google Microsoft Uber
ShopeeViews 29

Problem Statement

Excel Sheet Column Number LeetCode Solution says that Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number.

Excel Sheet Column NumberPin

For example:

A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28 
...

 

Example 1:

Input:

 columnTitle = "A"

Output:

 1

Example 2:

Input:

 columnTitle = "AB"

Output:

 28

Example 3:

Input:

 columnTitle = "ZY"

Output:

 701

 

Constraints:

  • 1 <= columnTitle.length <= 7
  • columnTitle consists only of uppercase English letters.
  • columnTitle is in the range ["A", "FXSHRXW"].

Approach

Idea

  1. This is a famous interview problem or you can say it’s a brain teaser. We will look into the detailed approach here.
  2. Essentially, what we are asked to do here is to convert a number in the base 26 numeral system to a decimal number. This is a standard algorithm, where we iterate over the digits from right to left and multiply them by the base to the power of the position of the digit.
  3. While iterating over the string we’ll store the present character value in a.
  4. Here A to Z represents by 1 to 26. No value starts with 0, that’s why we’re adding 1.
  5. Now in its multiply it with 26 and add a with it.
  6. A dry run is explained here. We could this process iteratively. Start by looking at the first digit “B”. Add the int equivalent of “B” to the running sum and continue. Every time we look at the following digit multiply our running sum by 26 adding the next digit to signify we are changing places. “B”=2, “BD”=2*26+4,”BCY”=(2*26+3)*26+25.
  7. Hence, we finally get the required column number.

 

Code

Excel Sheet Column Number C++ Solution:

class Solution {
public:
    int titleToNumber(string columnTitle) {
        int i,n=columnTitle.size();
        int ans=0;
        for(i=0;i<n;i++)
        {
            ans*=26;
            ans+=columnTitle[i]-'A'+1;
        }
        return ans;
    }
};

Excel Sheet Column Number Java Solution:

class Solution {
    public int titleToNumber(String columnTitle) {
        int i,n=columnTitle.length();
        int ans=0;
        for(i=0;i<n;i++)
        {
            ans*=26;
            ans+=columnTitle.charAt(i)-'A'+1;
            
        }
        return ans;
    }
}



Complexity Analysis of Excel Sheet Column Number LeetCode Solution

Time Complexity

Time complexity is O(N), N = size of the input string. We are traversing the string exactly one time hence the complexity is linear.

Space Complexity

Space complexity is O(1). We are not taking any extra space.

Top Interview Questions

S.No Interview Question Number of times has been asked
1Delete a node in doubly linked list2815
2Java program to find the number of Nodes in a Binary Tree2498
3Reverse a string without affecting special characters2453
4Delete a node of a linked list at given position1972
5Palindrome using Recursion1775
6Insert nodes in a linked list in a sorted way (Ascending Order)1656
7Find elements pair from array whose sum equal to number1644
8Sort Elements by Frequency of Occurrences1626
9Write a program to print all permutations of a given string1599
10Find Minimum Distance Between Two Numbers in an Array1470
11Create a Doubly Linked List1443
12Quick Sort1415
13Reverse an Array1408
14Smallest window in a string containing all characters of another string1393
15Find a Triplet That Sum to a Given Value1355
16Recursively remove all adjacent duplicates1351
17First Repeating Element1334
18Arrange Even and Odd number such that Odd comes after Even1318
19Sum of numbers in String1310
20Smallest Positive Number Missing in an Unsorted Array1277
21Check if the Elements of an Array are Consecutive1250
22Detect a loop in the Linked List1234
23Largest Sum Contiguous Subarray1228
24Quick Sort on SIngly Linked List1212
25Subarray with Given Sum1209
26Print all Possible Combinations of R Elements in a given Array of size N1201
27Recursive function to do substring search1195
28Find the Maximum Repeating Number in Array1149
29Binary Tree Level order traversal in Java1121
30Find the First and Second Smallest Elements1118
31Check if two linked lists are identical1100
32Maximum Subarray Sum using Divide and Conquer1098
33Remove characters from first string which are in second1065
34Find Leaders in an Array1057
35Swap nodes in the linked list1031
36Find the Number Occurring Odd Number of Times in an Array999
37Arrange given Numbers to Form the Biggest Number II991
38Find the second most frequent character983
39Given a string find its first non-repeating character962
40Find Triplet in Array With a Given Sum961
41Total number of occurrences of a given item in the linked list950
42Given a sorted array and a number x, find the pair in array whose sum is closest to x950
43A Program to check if strings are rotations of each other or not941
44Print all possible words from phone digits927
45Find the Missing Number922
46Rearrange Positive and Negative Numbers Alternatively in Array916
47Longest Palindromic Substring901
48Segregate even and odd nodes in a linked list880
49Print Longest common subsequence877
50Union and Intersection of Two Linked Lists870
51Transform one string to another using minimum number of given operations861
52Check rearranged string can form a palindrome841
53Rearrange given Array in Maximum Minimum Form841
54Count Possible Triangles818
55Iterative Implementation of Quick Sort813
56Multiplication of Two Matrices796
57Check if the linked list is palindrome792
58Count of Triplets With Sum Less than Given Value788
59Rotate a Linked List788
60Stock Buy Sell to Maximize Profit784
61Concatenation of two strings756
62Tug of War755
63Count Number of Substrings with K Distinct Character’s750
64Print all duplicates in the input string748
65Find Nearest Greater and Smaller Element743
66The Celebrity Problem735
67Find Pythagorean Triplets from Array735
68Reverse String Without Temporary Variable729
69Remove ‘b’ and ‘ac’ from a given string726
70Find all Common Elements in Given Three Sorted Arrays726
71Remove all duplicates in an unsorted linked list708
72Find the Row with Maximum Number of 1’s702
73Find the Peak Element from an Array696
74Find the subarray whose sum is equal to a given number X692
75Remove Minimum Characters so that Two Strings Become Anagrams685
76Insertion Sort685
77Find Smallest Missing Number in a Sorted Array684
78Addition of Two Matrices681
79A Product Array Puzzle681
80Implement Two Stacks in an Array674
81Generate all Binary Strings Without Consecutive 1’s670
82Maximum Sum of Non Consecutive Elements667
83Maximum Product Subarray II658
84Lexicographic rank of string651
85Multiplication of Previous and Next641
86Check if Two given Matrices are Identical641
87Merge K Sorted Arrays and Print Sorted Output631
88Subtraction of Two Matrices630
89Move All the Zeros to the End of the Given Array626
90Divide a string in N equal parts620
91Online Algorithm for Checking Palindrome in a Stream620
92Form Minimum Number from Given Sequence of D’s and I’s620
93Check whether two strings are anagram of each other611
94Maximum Circular Subarray Sum607
95Sort a linked list that is sorted alternating ascending and descending607
96Remove recurring digits in a given number607
97Sort a stack using a temporary stack603
98Find the Minimum Element in a Sorted and Rotated Array603
99Move last element of the Linked List at first place600
100Subarray and Subsequence596
101First Circular Tour to Visit all the Petrol Bunks596
102Largest Subarray with Equal Number of 0’s and 1’s592
103Compare two strings(linked lists)591
104Flattening a linked list589
105Maximum Element in an Array which is Increasing and then Decreasing588
106Palindrome Permutations of a String581
107Elements Appear more than N/K times in Array580
108Majority Element573
109Minimum insertions to form a shortest palindrome571
110Run length encoding571
111Print all permutations with repetition570
112Palindromes in a given range569
113Pangram Checking565
114Merge a linked list into another at alternate positions563
115Minimum Characters to be Added at Front to Make String Palindrome561
116Rearrange a given linked list in-place561
117Remove all duplicates in a sorted linked list561
118Minimum number of Merge Operations to make an Array Palindrome557
119Rotate string to get lexicographically minimum string556
120Most repeating character in a string555
121Repeated Subsequence of Length Two or More553
122Reorder an Array According to the Given Indexes548
123Print all anagrams together in a sequence of words548
124Pancake Sorting Problem540
125Merge Overlapping Intervals II536
126Clone a Linked List with next and random pointer535
127Two Sum Leetcode Solution533
128Size of The Subarray With Maximum Sum524
129Transpose of a Matrix522
130Removing Spaces from a String using stringstream518
131Remove Extra Spaces from a String518
132Check if a given string is a rotation of a palindrome515
133Smallest Palindrome after Replacement514
134Partition Problem514
135Remove duplicates from a string513
136Maximum Sum Increasing Subsequence511
137Longest Palindrome can be Formed by Removing or Rearranging Characters511
138Check whether Strings are K Distance Apart or Not501
139Generate all Binary Strings from Given Pattern499
140Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized498
141Insert Node in the Sorted Linked List497
142Length of Longest valid Substring497
1433Sum Leetcode Solution494
144Delete Last Occurrence494
145Check if Two given Strings are Isomorphic to each other490
146Maximum difference between two elements such as larger element comes after smaller486
147Program to Toggle all Characters in a String481
148Count Minimum Steps to Get the given Array478
149Given string is interleaving of two other strings or not478
150Merge sort better than quick sort for linked lists474
151Number of Smaller Elements on Right Side472
152Find Pair with Given Difference470
153Check length of a String is Equal to the Number Appended at its Last468
154Check if all Rows of a Matrix are Circular Rotations of Each Other468
155Longest Common Prefix using Divide and Conquer466
156Find nth node of the Linked list from the end466
157Sort 0s 1s and 2s in an Array457
158Find a Fixed Point in a Given Array456
159Print all interleavings of given two strings454
160Merge two sorted linked lists such that merged list is in reverse order452
161Find the Subarray of given length with Least Average452
162Compare Two Version Numbers452
163Reorder Array Using Given Indexes450
164Split linked list using alternate nodes449
165Reverse words in a given string448
166Print Reverse of a string (Recursion)446
167Median of Two Sorted Arrays LeetCode Solution444
168Print string of odd length in ‘X’ format434
169Swap Kth Node from beginning with Kth Node from End430
170Find K Length Subarray of Maximum Average430
171Find Element Using Binary Search in Sorted Array430
172Print all Palindromic Partitions of a String426
173Find Duplicates in an Array in Most Efficient Way424
174print all palindromic partitions420
175Maximum Length of Chain Pairs414
176Flatten a multilevel linked list414
177Shortest Superstring Problem413
178Check if String Follows Order of Characters by a Pattern or not410
179Sorting a K Sorted Array408
180Sort a String According to Another String401
181Longest Span with same Sum in two Binary Arrays II397
182Reverse a Linked List in groups394
183Find a Sorted Subsequence of size 3391
184Program to add two binary digits389
185Find the two Numbers with Odd Occurrences in an Unsorted Array386
186Recursively print all the sentences that can be formed from list of word lists385
187Longest Common Prefix Using Binary Search II382
188Reverse a Singly Linked List (Iterative/Non-Recursive)380
189Kth Non-repeating Character376
190Rearrange a linked list in Zig-Zag376
191Caesar Cipher375
192Check if String can Become Empty by Recursively Deleting given Substring374
193Pancake Sorting373
194Rotate Image by 90 degrees370
195Longest Common Prefix Word by Word Matching367
196Perfect Reversible String364
197Permutations of a Given String Using STL363
198Merging Two Sorted Arrays361
199Increasing Subsequence of Length three with Maximum Product361
200Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes360
201Find the point where a monotonically increasing function becomes positive first time358
202Sort a linked list with 0s, 1s and 2s357
2031`s and 2`s complement of binary number355
204Find First non-repeating character in a string355
205Four Elements that Sum to Given353
206Delete N nodes after M351
207List items containing all characters of a given word350
208Longest Common Prefix using Character by Character Matching347
209Count Number of Occurrences in a Sorted Array344
210Split a string338
211Minimum Characters to be Removed to Make a Binary String Alternate338
212Palindrome string (number)338
213Check if a Linked list of Strings form a Palindrome332
214Print All Distinct Elements of the Array330
215Recursive Implementation of atoi()330
216Sorting the array of strings329
217Convert a String that is Repetition of a Substring of Length K327
218Find the first Repeating Number in a Given Array325
219Maximum occurring character in a string324
220Even Substring Count324
221Reverse a singly linked list recursively323
222Valid Parentheses LeetCode Solution322
223Can we reverse a linked list in less than O(n) time ?321
224Binary Tree to Doubly linked list321
225Print Shortest Path to Print a String on Screen320
226Sort Elements by Frequency II316
227Convert string1 to string2 in one edit316
228Reverse a String using Stack316
229Nth Character in Concatenated Decimal String316
230Lower Case To Upper Case313
231wildcard character matching313
232Maximum Subarray Leetcode Solution311
233Merge Two Sorted Arrays310
234Find the Lost Element From a Duplicated Array310
235Count the number of words308
236Split Four Distinct Strings307
237Find middle of the Linked List304
238Count the Pairs at Same Distance as in English Alphabets298
239Longest Common Subsequence with Permutations298
240Next Greater Element in an Array294
241Matrix Chain Multiplication using Dynamic Programming292
242Palindrome Permutation287
243Searching a node in a Binary Search Tree283
244Find Nth Node283
245Find All Pairs With a Given Difference281
246Triplet from three linked lists with given sum280
247Roman to Integer Leetcode Solution279
248Delete a Tree279
249String(represents an integer) to value275
250Print all Possible Ways to Break a String in Bracket Form275
251Reverse a String275
252Reverse Bits271
253Binary Tree271
254Delete a node under given conditions270
255Change Gender of a given String270
256Word Search Leetcode Solution269
257Sort an array of strings268
258Number of sub-strings which recursively add up to 9265
259How to Efficiently Implement k Stacks in a Single Array?265
260Longest Common Extension264
261Remove middle points in a linked list of line segments264
262Count Pairs With Given Sum263
263Toeplitz Matrix262
264Meeting Rooms II LeetCode Solution261
265First non Repeating Element261
266Remove spaces from a string261
267Longest Palindromic Substring LeetCode Solution260
268Shuffle a given Array258
269Repeated Substring Pattern257
270Move all negative elements to one side of array257
271Min Stack255
272N queen problem253
273Find, second, frequent, character249
274Number of Islands LeetCode Solution249
275Dijkstra Algorithm248
276Cuckoo sequence program247
277House Robber Leetcode Solution247
278Most Frequent Element in an Array246
279Clone a linked list with next and random pointer (Hashing)245
280Minimize the maximum difference between the heights244
281Sort linked which is sorted on absolute values243
282Max stack243
283Expression Evaluation242
284Search Insert Position Leetcode Solution242
285Fibonacci numbers240
286Valid Palindrome Leetcode Solution238
287KMP Algorithm237
288Plus One Leetcode Solution237
289How to Delete a Linked List237
290Sudoku Solver236
291Min Stack Leetcode Solution236
292Word Search235
293Reverse words in a string234
294Subset Leetcode233
295Evaluation of Postfix Expression233
296Combination Sum Leetcode Solution232
297Number Of 1 bits232
298Backspace String Compare227
299Rabin Karp Algorithm226
300Pair of Positive Negative Values in an Array226
301Merge Sorted Arrays Leetcode Solution226
302Set Matrix Zeroes224
303Sqrt(x) Leetcode Solution224
304Contains Duplicate II Leetcode Solution223
305Reversing a Queue223
306Tower Of Hanoi222
307Subarray with 0 sum221
308Combination Sum220
309Product of array except self219
310Common elements in all rows of a given matrix219
311Intersection of Two Arrays II Leetcode Solution218
312Integer to Roman Leetcode Solution217
313Count subarrays with equal number of 1’s and 0’s216
314String Compression215
315Pascal Triangle Leetcode215
316Delete middle element of a stack215
317Reverse individual words214
318Find Top K (or Most Frequent) Numbers in a Stream213
319Construct Binary Tree from Given Inorder and Preorder Traversals213
320Minimum swaps required to bring all elements less than or equal to k together212
321Second Most Repeated Word in a Sequence212
322Sliding Window Technique212
323Pow(x, n) Leetcode Solution211
324Segregate even and odd numbers211
325Bellman Ford Algorithm211
326Add Binary Leetcode Solution211
327Arithmetic Expression Evaluation211
328Palindrome Linked List Leetcode Solution210
329Next Permutation210
330Page Replacement Algorithms in Operating Systems210
331Implementation of Deque using Doubly Linked List210
332Count of index pairs with equal elements in an array210
333Kruskal Algorithm209
334Single Number Leetcode Solution209
335Contains Duplicate208
336Find sum of non-repeating elements (distinct) elements in an array208
337Postfix to Infix Conversion208
338Design a stack that supports getMin() in O(1) time and O(1) extra space207
339K-th Smallest Element in a Sorted Matrix207
340Minimum Value to Get Positive Step by Step Sum Leetcode Solution207
341Count Odd Numbers in an Interval Range Leetcode Solution207
342Maximum Subarray206
343Maximum Number of Balloons Leetcode Solution206
344Sort elements by frequency206
345Third Maximum Number Leetcode Solution204
346Group Words With Same Set of Characters204
347Permutations Leetcode Solution204
348Longest Common Prefix Leetcode Solution204
349Majority Element Leetcode Solution203
350Find Numbers with Even Number of Digits Leetcode Solution203
351Top K Frequent Words203
352Convex Hull Algorithm203
353Longest Substring Without Repeating Characters LeetCode Solution202
354Spiral Matrix LeetCode Solution202
355Swap Nodes in Pairs Leetcode Solutions202
356Find Lucky Integer in an Array Leetcode Solution202
357Minimum operation to make all elements equal in array201
358Sum of minimum and maximum elements of all subarrays of size k201
359Sorting array using Stacks201
360Find the Town Judge Leetcode Solution200
361Count subarrays having total distinct elements same as original array200
362Evaluate Division200
363Scramble String200
364Smallest Subarray with k Distinct Numbers200
365Special Number198
366Merge Two Sorted Lists Leetcode Solutions198
367Check if two arrays are equal or not197
368First element occurring k times in an array197
369Reverse a Number Using Stack197
370Prefix to Infix Conversion196
371Group Anagrams196
372Minimum Path Sum196
373Given two unsorted arrays find all pairs whose sum is x196
374Search in Rotated Sorted Array Leetcode Solution196
375Count Primes Leetcode Solutions196
376Pascal’s Triangle II Leetcode Solution195
377Best Time to Buy and Sell Stock  II Leetcode Solution195
378Number of Good Pairs Leetcode Solution195
379Maximum Distance Between two Occurrences of Same Element in Array194
380Huffman Coding194
381Find duplicates in a given array when elements are not limited to a range194
382Reversing the First K elements of a Queue194
383Single Number193
384Power of Two Leetcode Solution193
385Minimum Absolute Difference Leetcode Solution193
386Minimum Steps to reach target by a Knight193
387Fizz Buzz Leetcode193
388House Robber II Leetcode Solution192
389Sort Array by Increasing Frequency Leetcode Solution192
390Coin Change 2 Leetcode Solution192
391Missing Number Leetcode Solution192
392How to Implement Stack Using Priority Queue or Heap?191
393Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution191
394Maximal Square191
395Maximum possible difference of two subsets of an array191
396Running Sum of 1d Array Leetcode Solution191
397Range Sum Query 2D – Immutable Leetcode Solution191
398Find All Numbers Disappeared in an Array Leetcode Solution190
399Top K Frequent Elements190
400Unique Paths Leetcode Solution189
401Sorting using trivial hash function189
402Max Consecutive Ones Leetcode Solution189
403Matrix Diagonal Sum Leetcode Solution189
404Subarray Sum Equals K LeetCode Solution189
405How Many Numbers Are Smaller Than the Current Number Leetcode Solution189
406Subset sum problem188
407Check if Array Contains Contiguous Integers With Duplicates Allowed188
408Palindrome Substring Queries188
409Decode String188
410Leetcode Permutations188
411Unique Paths188
412Expression Contains Redundant Bracket or Not188
413Zigzag Conversion188
414Fibonacci Number LeetCode Solution187
415Difference between highest and least frequencies in an array187
416Find Winner on a Tic Tac Toe Game Leetcode Solution187
417Subarray Sum Equals k187
418Sort Integers by The Number of 1 Bit Leetcode Solution187
419Find The Duplicate Number187
420Smallest Element Repeated Exactly K Times187
421Subtract the Product and Sum of Digits of an Integer Leetcode Solution187
422Happy Number Leetcode Solution187
423Monotonic Array LeetCode Solution186
424Find the Closest Palindrome number186
425Cumulative Frequency of Count of Each Element in an Unsorted Array186
426Check If N and Its Double Exist Leetcode Solution186
427Convert String To Int186
428Reverse Integer186
429Reverse Vowels of a String Leetcode Solution186
430Nth Catalan Number186
431Letter Case Permutation186
432Print All Distinct Elements of a Given Integer Array185
433Find Number of Employees Under every Employee185
434Shuffle the Array Leetcode Solution185
435Length of the largest subarray with contiguous elements185
436Find top three repeated in array185
437Remove Duplicates from Sorted Array Leetcode Solution185
438Trapping Rain Water Leetcode Solution185
439Capacity To Ship Packages Within D Days Leetcode Solution184
440Bipartite Graph184
441Sort a stack using recursion184
442Reverse Words in a String III LeetCode Solution184
443Best Time to Buy and Sell Stock III Leetcode Solution184
444Implement Stack and Queue using Deque184
445Find all pairs (a, b) in an array such that a % b = k184
446Find Median from data Stream184
447Find the first repeating element in an array of integers183
448Maximum Depth of Binary Tree Leetcode Solution183
449LRU Cache Implementation183
450Find the Duplicate Element182
451Minimum Moves to Equal Array Elements Leetcode Solution182
452Prim’s Algorithm182
453Priority Queue Using Singly Linked List182
454Find Minimum In Rotated Sorted Array182
455Generate a String With Characters That Have Odd Counts Leetcode Solution182
456Reverse a String181
457Merge Two Sorted Linked Lists181
458Subarrays with distinct elements181
459Reverse a Stack Using Recursion181
460Delete a Node from linked list without head pointer181
461Longest Common Subsequence181
462Sum of Subarray Ranges Leetcode Solution181
463Count pairs from two linked lists whose sum is equal to a given value181
464Kth largest element in an Array Leetcode Solutions181
465Integer to English words181
466Count Substrings with equal number of 0s, 1s and 2s181
467The K Weakest Rows in a Matrix Leetcode Solution180
468Find elements which are present in first array and not in second180
469Sorting a Queue without Extra Space180
470Fizz Buzz180
471Find the Difference Leetcode Solution179
472Find Common Characters Leetcode Solution179
473Next Greater Element I Leetcode Solution179
474Remove Minimum Number of Elements Such That no Common Element Exist in both Array179
475Edit Distance179
476Kth Largest Element in a Stream Leetcode Solution178
477Concatenation of Array LeetCode Solution178
478MiniMax Algorithm178
479Reverse a linked list178
480Find First and Last Position of Element in Sorted Array Leetcode Solution178
481Target Sum178
482Count and Say178
483Word Ladder LeetCode Solution178
484Kids With the Greatest Number of Candies Leetcode Solution178
485Degree of an array178
486Print all subarrays with 0 sum177
487Top View of Binary Tree177
488Text Justification LeetCode Solution177
489Number of Steps to Reduce a Number to Zero Leetcode Solution177
490Excel Sheet Column Number Leetcode Solution177
491Multiply Strings Leetcode Solution177
492Floyd Warshall Algorithm177
493Longest Common Prefix using Trie177
494Balanced Binary Tree Leetcode Solution176
495Priority Queue in C++176
496Iterative Tower of Hanoi176
497Merge Overlapping Intervals176
498Longest subarray not having more than K distinct elements175
499Shortest Palindrome175
500Pair with given product175
501Koko Eating Bananas Leetcode Solution175
502Flood Fill LeetCode175
503Design Parking System Leetcode Solution175
504Max Area of Island175
505Move Zeroes LeetCode Solution174
506Postfix to Prefix Conversion174
507Check if a given array contains duplicate elements within k distance from each other174
508Peak Index in a Mountain Array174
509Prefix to Postfix Conversion174
510Count and Say Leetcode Solution174
511Valid Parenthesis String174
512Intersection of Two Arrays173
513Length of Last Word Leetcode Solution173
514Mobile Numeric Keypad Problem173
515Substring With Concatenation Of All Words173
516Jump Game Leetcode Solution173
517Shuffle String Leetcode Solution173
518Find four elements that sum to a given value (Hashmap)173
519Find subarray with given sum (Handles Negative Numbers)173
520Recursion173
521Find distinct elements common to all rows of a matrix173
522Implement a stack using single queue173
523Implement Stack using Queues173
524Zigzag Conversion LeetCode Solution173
525Find N Unique Integers Sum up to Zero Leetcode Solution173
526The Stock Span Problem173
527Container with Most Water172
528Iterative Inorder Traversal of a Binary Tree172
529Excel Sheet Column Title Leetcode Solution172
530Count number of triplets with product equal to given number172
531Contiguous Array Leetcode172
532Find Index of Closing Bracket for a Given Opening Bracket in an Expression172
533Convert array into Zig-Zag fashion172
534Find missing elements of a range172
535Slowest Key Leetcode Solution172
536Longest Common Prefix using Sorting171
537Best Time to Buy and Sell Stock171
538Maximum sum rectangle in a 2D matrix171
539Last Stone Weight171
540Delete Node in a Linked List Leetcode Solution171
541Find any one of the multiple repeating elements in read only array170
542Minimum Operations to convert X to Y170
543Largest Perimeter Triangle Leetcode Solution170
544Minimum Bracket Reversals170
545K-th Distinct Element in an Array170
546Relative Sort Array Leetcode Solution170
547Smallest Subarray With all Occurrences of a Most Frequent Element170
548Convert a normal BST to Balanced BST170
549Build Array From Permutation Leetcode Solution169
550Valid Sudoku169
551Shuffle an Array169
552Next Greater Frequency Element169
553Implementation of Deque using circular array168
554Sum of Left Leaves Leetcode Solutions168
555Distribute Candies to People Leetcode Solution168
556Assign Cookies Leetcode Solution168
557First negative integer in every window of size k168
558Change the Array into Permutation of Numbers From 1 to N168
559Check for Balanced Parentheses in an Expression168
560Arrange given numbers to form the biggest number168
561Jewels and Stones Leetcode Solution168
562Find Words That Can Be Formed by Characters Leetcode Solution167
563Shortest Path in a Grid with Obstacles Elimination LeetCode Solution167
564Rearrange a binary string as alternate x and y occurrences167
565Maximum path sum in a triangle167
566Is Subsequence Leetcode Solution167
567Gold Mine Problem167
568Isomorphic Strings Leetcode Solution167
569The Knapsack Problem167
570Valid Anagrams167
571Integer to Roman167
572Group Multiple Occurrence of Array Elements Ordered by first Occurrence167
573Insert Interval Leetcode Solution167
574Minimum Delete Operations to make all Elements of Array Same166
575Decode Ways166
576Sieve of Eratosthenes166
577Linked List Cycle II LeetCode Solution166
578N-th Tribonacci Number Leetcode Solution166
5793Sum Closest LeetCode Solution166
580Unique Binary Search Trees166
581Convert Sorted Array to Binary Search Tree Leetcode Solution166
58201 Matrix LeetCode Solution166
583Hamming Distance166
584How to check if two given sets are disjoint?165
585Count the number of nodes at given level in a tree using BFS165
586Count all subsequences having product less than K165
587Island Perimeter Leetcode Solution165
588Find the smallest positive integer value that cannot be represented as sum of any subset of a given array165
589Remove Linked List Elements Leetcode Solution165
590Same Tree LeetCode Solution165
591Rotate List Leetcode Solution165
592K Empty Slots LeetCode164
593Maximum Distance in Array164
594Trapping Rain Water LeetCode Solution164
595Minimum number of distinct elements after removing m items164
596Combinations Leetcode Solution164
597LRU Cache LeetCode Solution164
598Maximum difference between first and last indexes of an element in array164
599Minimum Knight Moves LeetCode Solution164
600Distance Between Bus Stops Leetcode Solution163
601Word Pattern163
602Summary Ranges Leetcode Solution163
603Minimum number of subsets with distinct elements163
604Find minimum difference between any two elements163
605Rotate Image LeetCode Solution163
606Minimum insertions to form a palindrome with permutations allowed162
607Printing brackets in Matrix Chain Multiplication Problem162
608Frog Jump Leetcode Solution162
609Sort Array By Parity LeetCode Solution162
610Maximum Number of Chocolates to be Distributed Equally Among k Students162
611Applications of Breadth First Search and Depth First Search162
612Find Sum of all unique sub-array sum for a given array162
613Coin Change Problem162
614Find if an Expression has Duplicate Parenthesis or Not162
615Find the Duplicate Number LeetCode Solution161
616Replace Elements with Greatest Element on Right Side Leetcode Solution161
617Best Time to Buy and Sell Stock LeetCode Solution161
618Minimum Cost to Hire K Workers161
619Word Wrap Problem161
620Permutation in String Leetcode Solution160
621XOR Operation in an Array Leetcode Solution160
622Find Maximum Level sum in Binary Tree160
623Distance of nearest cell having 1 in a binary matrix160
624License Key Formatting Leetcode Solution160
625House Robber160
626Minimum Depth of Binary Tree Leetcode Solution160
627Remove All Occurrences of a Substring LeetCode Solution160
628Stone Game LeetCode160
629Defanging an IP Address Leetcode Solution160
630Segregate 0s and 1s in an Array159
631Kth Missing Positive Number Leetcode Solution159
632Maximum Consecutive Numbers Present in an Array159
633Longest Increasing Subsequence159
634Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest159
635Sort Characters By Frequency LeetCode Solution159
636Smallest Good Base159
637Painting Fence Algorithm159
638Queries for counts of array elements with values in given range158
639Power of Four Leetcode Solution158
640Non-overlapping sum of two sets158
641Check If It Is a Straight Line Leetcode Solution158
642Binary Tree Zigzag Level Order Traversal LeetCode Solution158
643Reverse a stack without using extra space in O(n)158
644Longest Substring with At Most K Distinct Characters LeetCode Solution158
645K Empty Slots157
646Find Largest d in Array such that a + b + c = d157
647Valid Palindrome II Leetcode Solution157
648Reorganize String157
649Iterative Method to find Height of Binary Tree157
650Best Time to Buy and Sell Stock with Cooldown Leetcode Solution157
651Merge Two Balanced Binary Search Trees157
652Isomorphic Strings157
653Tracking current Maximum Element in a Stack157
654Count Good Nodes in Binary Tree Leetcode Solution157
655Optimal Account Balancing LeetCode Solution157
656GCD Of Two Numbers156
657Longest Substring with At Least K Repeating Characters LeetCode Solution156
658Wiggle Sort156
659Partition Labels LeetCode Solution156
660Check If Two String Arrays are Equivalent Leetcode Solution156
661Number of Provinces Leetcode Solution156
662Flipping an Image LeetCode Solution156
663How to Create Mergable Stack?156
664Sum of All Odd Length Subarrays Leetcode Solution156
665String to Integer (atoi) LeetCode Solution156
666Strobogrammatic Number LeetCode Solution156
667Moving Average from Data Stream Leetcode Solution156
668Employee Free Time LeetCode Solution156
669Inorder Successor of a node in Binary Tree155
670Reservoir Sampling155
671Form minimum number from given sequence155
672Convert an array to reduced form155
673Permutation Sequence LeetCode Solution155
674Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions155
675Letter Combinations of a Phone Number155
676Sum of f(a[i], a[j]) over all pairs in an array of n integers155
677Largest Sum Contiguous Subarray155
678BFS vs DFS for Binary Tree155
679Find the Distance Value Between Two Arrays Leetcode Solution155
680Increasing Decreasing String Leetcode Solution155
681Check if a queue can be sorted into another queue using a stack155
682Maximum Number of Coins You Can Get Leetcode Solution155
683Populating Next Right Pointers in Each Node154
684Delete consecutive same words in a sequence154
685Maximum Number of Occurrences of a Substring Leetcode Solution154
686Subset Sum Leetcode154
687Lucky Numbers in a Matrix Leetcode Solution154
688Reducing Dishes LeetCode Solution154
689Ugly Number Leetcode Solution154
690To Lower Case Leetcode Solution154
691Path With Maximum Minimum Value LeetCode Solution154
692Sort Array by Increasing Frequency Leetcode Solution153
693Reversing a Queue using Recursion153
694Find the node with minimum value in a Binary Search Tree153
695Find whether an array is subset of another array153
696Maximum Product of Three Numbers LeetCode Solution153
697Print the Fibonacci numbers in reverse order153
698Longest Increasing Path in a Matrix LeetCode Solution153
699Hamming Distance Leetcode Solution153
700Find the Smallest Divisor given a Threshold Leetcode Solution153
701Number of Dice Rolls With Target Sum LeetCode Solution153
702Majority Element II Leetcode Solution153
703Find Leaves of Binary Tree LeetCode Solution153
704Valid Palindrome153
705Reverse Only Letters LeetCode Solution152
706Remove Invalid Parentheses Leetcode Solution152
707Delete Nth node from the end of the given linked list152
708Valid Perfect Square Leetcode Solution152
709Add and Search Word – Data structure design LeetCode152
710Find pairs with given sum such that elements of pair are in different rows152
711Numbers with prime frequencies greater than or equal to k152
712Construct BST from given Preorder Traversal152
713Recover Binary Search Tree152
714Factorial Trailing Zeroes Leetcode Solution152
715Dynamic Programming Basics152
716Partition Array Into Three Parts With Equal Sum Leetcode Solution152
717Unique Paths II Leetcode Solution152
718Decompress Run-Length Encoded List Leetcode Solution151
719Edit Distance LeetCode Solution151
720Convert a Number to Hexadecimal Leetcode Solution151
721Longest Span with same Sum in two Binary arrays151
722Largest subarray with equal number of 0s and 1s151
723Binary Tree zigzag level order Traversal151
724Restore IP Addresses Leetcode Solution150
725Binomial Coefficient150
726Deletion in a Binary Tree150
727Maximum Product of Two Elements in an Array Leetcode Solution150
728Minimum Cost For Tickets Leetcode Solution150
729Rank Transform of an Array Leetcode Solution149
730Find Pair with Greatest Product in Array149
731Best Meeting Point LeetCode Solution149
732Stack Permutations (Check if an array is stack permutation of other)149
733Find unique character in a string149
734Symmetric Tree Leetcode Solution149
735Merge Two Binary Trees LeetCode Solution149
736Find the largest multiple of 3149
737Minimum Height Trees149
738Finding K closest element149
739Keyboard Row Leetcode Solution149
740Minimum Distance Between BST Nodes Leetcode Solution149
741Maximum 69 Number Leetcode Solution149
742Merge K Sorted Linked Lists149
743Bubble sort using two Stacks149
744Find Maximum Depth of Nested Parenthesis in a String149
745Remove brackets from an algebraic string containing + and – operators148
746Elements to be added so that all elements of a range are present in array148
747Morris Traversal148
748Robot Room Cleaner Leetcode Solution148
749Generate all possible sorted arrays from alternate elements of two given sorted arrays148
750Binary Tree Maximum Path Sum LeetCode Solution148
751Race Car LeetCode Solution148
752Count quadruples from four sorted arrays whose sum is equal to a given value x148
753Bulb Switcher LeetCode Solution148
754Perform String Shifts Leetcode148
755Word Pattern LeetCode Solution148
756Invert Binary Tree LeetCode Solution148
757Jump Game148
758Sorted Linked List to Balanced BST148
759Growable array based stack148
760Evaluate Reverse Polish Notation LeetCode Solution147
761First Unique Character in a String LeetCode Solution147
762Non-decreasing Array LeetCode Solution147
763Kth ancestor of a node in binary tree147
764Number of NGEs to the Right147
765Program for Bridge and Torch problem147
766Minimum time required to rot all oranges147
767Queue based approach for first non-repeating character in a stream147
768Largest rectangular sub-matrix whose sum is 0147
769k-th missing element in increasing sequence which is not present in a given sequence147
770Diagonal Traversal of Binary Tree147
771Student Attendance Record I Leetcode Solution147
772Find All Duplicates in an Array LeetCode Solution147
773Maximum Depth of N-ary Tree Leetcode Solution147
774Maximum Length of a Concatenated String with Unique Characters Leetcode Solution146
775String Compression LeetCode Solution146
776Check for Palindrome after every character replacement Query146
777Merge Sorted Array LeetCode Solution146
778Minimum number of jumps to reach end146
779Largest Rectangle in Histogram LeetCode Solution146
780Number of Islands II LeetCode Solution146
781Tiling Problem146
782Search in a Binary Search Tree Leetcode Solution146
783Relative Ranks Leetcode Solution146
784Nested List Weight Sum II LeetCode Solution146
785String comparison containing wildcards146
786Remove Nth Node From End of List Leetcode Solution146
787Valid Number146
788Remove Duplicates from Sorted List LeetCode Solution146
789Snakes and Ladders LeetCode Solution146
790N-Queens LeetCode Solution146
791Maximum Difference Between Increasing Elements LeetCode Solution145
792Base 7 Leetcode Solution145
793Search a 2D Matrix II Leetcode Solution145
794Count items common to both the lists but with different prices145
795Sort an array according to the order defined by another array145
796Special Array With X Elements Greater Than or Equal X Leetcode Solution145
797Interval Tree145
798Find Median from Data Stream LeetCode Solution145
799Find if Path Exists in Graph Leetcode Solution145
800Minimum swaps to make sequences increasing145
801Partition to K Equal Sum Subsets Leetcode Solution145
802Linked List Cycle145
803Minimize Maximum Pair Sum in Array LeetCode Solution145
804Iterative Preorder Traversal144
805Number Complement Leetcode Solution144
806Print a Binary Tree in Vertical Order144
807Split a String in Balanced Strings Leetcode Solution144
808Final Prices With a Special Discount in a Shop Leetcode Solution144
809Check if Two Expressions With Brackets are Same144
810Circular Queue144
811Check If Array Pairs Are Divisible by k LeetCode Solution144
812Crawler Log Folder Leetcode Solution144
813Alien Dictionary LeetCode Solution144
814A Space Optimized DP solution for 0-1 Knapsack Problem144
815Transpose Graph144
816Reorder Data in Log Files LeetCode Solution144
817One Edit Distance LeetCode Solution143
818Minimum Time Visiting All Points Leetcode Solution143
819Nearest Exit from Entrance in Maze LeetCode Solution143
820Convert BST to Min Heap143
821Find all triplets with zero sum143
822Get Maximum in Generated Array Leetcode Solution143
823Longest Subarray Having Count of 1s One More than Count of 0s143
824Priority Queue using doubly linked list143
825Total Numbers With no Repeated Digits in a Range143
826Permutation Coefficient143
827Remove Duplicates from Sorted List II143
828Course Schedule II – LeetCode143
829Clone Graph LeetCode Solution143
830Sort Colors142
831Design a Stack With Increment Operation Leetcode Solution142
832Find the Only Repetitive Element Between 1 to N-1142
833Guess Number Higher or Lower LeetCode Solution142
834Maximum size subarray sum equals k142
835Last Stone Weight II LeetCode Solution142
836Minimum Swaps to Make Strings Equal Leetcode Solution142
837Partition List Leetcode Solution142
838Top K Frequent Words LeetCode Solution142
839Subset with sum divisible by m142
840Path with maximum average value142
841Sort Array By Parity II Leetcode Solution142
842Find the subarray with least average142
843Maximum Nesting Depth of the Parentheses Leetcode Solution142
844Brick Wall LeetCode Solution141
845Friends Pairing Problem141
846Minimum Jumps to Reach Home LeetCode Solution141
847Sorted Array to Balanced BST141
848Sum of nearest smaller and greater number141
849Check if a given array can represent Preorder Traversal of Binary Search Tree141
850Spiral Matrix II Leetcode Solution141
851Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution141
852Given an Array of Pairs Find all Symmetric Pairs in it141
853Count ways to reach the nth stair using step 1, 2 or 3141
854Check if an Array is Stack Sortable141
855Find All Possible Recipes from Given Supplies LeetCode Solution141
856Regular Expression Matching141
857Minimum Number of Taps to Open to Water a Garden LeetCode Solution141
858Count Distinct Elements in Every Window of Size K141
859Matrix Chain Multiplication141
860Insert Delete GetRandom140
861LCS (Longest Common Subsequence) of three strings140
862Level order Traversal in Spiral Form140
863Subsequence of Size K With the Largest Even Sum LeetCode Solution140
864Check whether a given Binary Tree is Complete or not140
865Can Place Flowers LeetCode Solution140
866Binary Search Tree Search and Insertion140
867Subarray Product Less Than K LeetCode Solution140
868Form Minimum Number From Given Sequence140
869Valid Parentheses Leetcode Solution140
870Brightest Position on Street LeetCode Solution140
871Maximum Profit in Job Scheduling Leetcode Solution140
872Tree Traversal (Preorder, Inorder & Postorder)140
873Guess Number Higher or Lower II139
874Union and Intersection of two Linked Lists139
875Insert into a Binary Search Tree Leetcode Solution139
876Find Maximum Sum Possible Equal Sum of Three Stacks139
877Count Subarrays with Same Even and Odd Elements139
878Rearrange an Array Such that arr[i] is equal to i139
879Range sum queries without updates139
880Distinct adjacent elements in an array139
881Find all permuted rows of a given row in a matrix139
882Minimum Sum Path in a Triangle139
883Sequences of given length where every element is more than or equal to twice of previous139
884Find distance between two nodes of a Binary Tree138
885An Interesting Method to generate Binary Numbers from 1 to n138
886Alien Dictionary138
887Shortest Word Distance Leetcode Solution138
888Count Negative Numbers in a Sorted Matrix LeetCode Solution138
889Convert Sorted List to Binary Search Tree138
890Check if stack elements are pairwise consecutive138
891Minimum sum of multiplications of n numbers138
892Destination City Leetcode Solution138
893Delete And Earn138
894Rearrange Spaces Between Words Leetcode Solution138
895Missing Element in Sorted Array LeetCode Solution138
896Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution138
897Daily Temperatures Leetcode Solution138
898A program to check if a binary tree is BST or not138
899Maximum Score After Splitting a String Leetcode Solution138
900BFS for Disconnected Graph138
901Identify and Mark Unmatched Parenthesis in an Expression138
902Find Common Characters Leetcode Solution138
903Repeated Substring Pattern LeetCode Solution137
9044Sum137
905Number of Days Between Two Dates LeetCode Solution137
906Lemonade Change Leetcode Solution137
907Diagonal Traversal LeetCode Solution137
908Construct Complete Binary Tree from its Linked List Representation137
909Three way partitioning of an array around a given range137
910GCDs of given index ranges in an array137
911Check if the given array can represent Level Order Traversal of Binary Search Tree137
912Range LCM Queries137
913Balanced Expression with Replacement137
914Special Positions in a Binary Matrix Leetcode Solution137
915Water Bottles Leetcode Solution137
916Set Matrix Zeroes Leetcode Solution137
917Longest Palindromic Subsequence136
918Robot Bounded In Circle LeetCode Solution136
919Vertical sum in a given binary tree136
920Diagonal Traverse LeetCode Solution136
921Queue using Stacks136
922Design Browser History LeetCode Solution136
923Merge Two Sorted Lists Leetcode136
924Least Number of Unique Integers after K Removals Leetcode Solution136
925Number of Equivalent Domino Pairs Leetcode Solution136
926Spiral Matrix III LeetCode Solution136
927Infix to Postfix136
928Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i136
929Three Consecutive Odds Leetcode Solution135
930Lexicographical Numbers Leetcode Solution135
931Construct the Rectangle Leetcode Solution135
932Trim a Binary Search Tree135
933Palindrome Partitioning Leetcode Solution135
934Averages of Levels in Binary Tree135
935Print Fibonacci sequence using 2 variables135
936Dividing Array into Pairs With Sum Divisible by K135
937K’th Largest Element in BST when modification to BST is not allowed135
938Number of Distinct Islands Leetcode Solution135
939Maximum Subarray Sum Excluding Certain Elements135
940Construct BST from its given Level Order Traversal134
941Median of Two Sorted Arrays134
942Remove Duplicates from Sorted List II LeetCode Solution134
943Binary array after M range toggle operations134
9443 Sum134
945Analyze User Website Visit Pattern LeetCode Solution134
946Queries for GCD of all numbers of an array except elements in a given range134
947Strongly Connected Component134
948Check if any two intervals overlap among a given set of intervals134
949Largest area rectangular sub-matrix with equal number of 1’s and 0’s134
950All Unique Triplets that Sum up to a Given Value134
951Word Break134
952Stone Game II Leetcode134
953Time Based Key-Value Store LeetCode Solution134
954Merging Intervals134
955Pattern Occurrences using Stack134
956Create Maximum Number133
957Maximum Frequency Stack Leetcode Solution133
958Sliding Window Maximum133
959Binary Tree Longest Consecutive Sequence LeetCode Solution133
960Count Submatrices With All Ones LeetCode Solution133
961Newman-Conway Sequence133
962Palindrome Partitioning133
963Iterative Postorder Traversal Using Two Stacks133
964Symmetric Tree133
965Maximize Sum of Array after K Negations Leetcode Solution133
966Largest Substring Between Two Equal Characters Leetcode Solution133
967Can Make Arithmetic Progression From Sequence Leetcode Solution133
968Find Maximum of Minimum for Every Window Size in a Given Array132
969Intersection of Two Linked Lists LeetCode Solution132
970Segment Tree132
971Split Array Into Consecutive Subsequences132
972Length of Longest Fibonacci Subsequence132
973Sign of the Product of an Array LeetCode Solution132
974Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space132
975My Calendar I LeetCode Solution132
976Difference Array | Range update query in O(1)132
977Depth First Search (DFS) for a Graph132
978Maximum Product Subarray132
979Count Primes in Ranges131
980Height of a generic tree from parent array131
981Find the Difference Leetcode Solution131
982Level Order Traversal of Binary Tree131
983Binary Search Tree Delete Operation131
984Climbing stairs131
985First missing positive131
986Find Duplicate Subtrees131
987Breadth First Search (BFS) for a Graph131
988Count pair with Given Sum131
989Minimum Height Trees LeetCode Solution131
990Maximum subsequence sum such that no three are consecutive131
991Find postorder traversal of BST from preorder traversal130
992Minesweeper LeetCode Solution130
993Insertion in a Binary Tree130
994Reverse Nodes in K-Group130
995Make The String Great Leetcode Solution130
996Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution130
997Double the first element and move zero to end130
998Boundary Traversal of binary tree130
999Find the First Circular Tour that visits all the Petrol Pumps130
1000Serialize and Deserialize Binary Tree130
1001Longest Nice Substring LeetCode Solution129
1002Kill Process LeetCode Solution129
1003Partition Equal Subset Sum129
1004Asteroid Collision LeetCode Solution129
1005Product of Array Except Self LeetCode Solution129
1006Kth Smallest Element in a BST Leetcode Solution129
1007Largest Number Leetcode Solution129
1008Count subarrays where second highest lie before highest129
1009Rearrange array such that even positioned are greater than odd129
1010Unique Paths II129
1011Number Of Longest Increasing Subsequence129
1012Valid Boomerang Leetcode Solution129
1013Largest divisible pairs subset129
1014Level order traversal using two Queues129
1015The Painter’s Partition Problem129
1016Find number of pairs in an array such that their XOR is 0129
1017Maximum Length of Repeated Subarray129
1018Compute nCr % p129
1019Collect maximum points in a grid using two traversals128
1020Construction of Longest Increasing Subsequence (N log N)128
1021Maximum Number of Ways to Partition an Array LeetCode Solution128
1022K Closest Points to Origin Leetcode Solution128
1023Binary Search Tree128
1024Number of palindromic paths in a matrix128
1025Decrypt String from Alphabet to Integer Mapping Leetcode Solution128
1026Friends Of Appropriate Ages LeetCode Solution128
1027Shortest Completing Word Leetcode Solution128
1028Scramble String LeetCode Solution128
1029String Matching in an Array Leetcode Solution128
1030Graph Valid Tree LeetCode Solution128
1031The Maze III LeetCode Solution128
1032Boolean Parenthesization Problem127
1033Advantages of BST over Hash Table127
1034Balanced Binary Tree127
1035Maximum length subsequence with difference between adjacent elements as either 0 or 1127
1036Find whether a subarray is in form of a mountain or not127
1037Next Greater Element III LeetCode Solution127
1038Ugly Numbers127
1039Build an Array With Stack Operations Leetcode Solution127
1040Construct Binary Tree from given Parent Array representation127
1041Find Peak Element127
1042Design Hit Counter LeetCode Solution127
1043Longest subsequence such that difference between adjacents is one127
1044Invalid Transactions LeetCode Solution127
1045Minimum Size Subarray Sum126
1046Maximum Sum of 3 Non-Overlapping Subarrays126
1047Kth Smallest Element in a Sorted Matrix LeetCode Solution126
1048Lowest Common Ancestor126
1049Maximum weight transformation of a given string126
1050Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’126
1051Available Captures for Rook Leetcode Solution126
1052Minimum Index Sum of Two Lists126
1053Maximum Product of Indexes of Next Greater on Left and Right126
1054Add two numbers126
1055Implement Trie (Prefix Tree) Leetcode Solution126
1056Ugly Number II LeetCode Solution126
1057Morris Inorder Traversal126
1058Maximize Distance to Closest Person LeetCode Solution125
1059Iterative Depth First Traversal of Graph125
1060Custom Sort String Leetcode Solution125
1061Move all negative elements to end in order with extra space allowed125
1062Path Sum II LeetCode Solution125
1063Regular Expression Matching Regular Expression Matching LeetCode Solution125
1064Find the minimum distance between two numbers125
1065Find a Peak Element II LeetCode Solution125
1066Defanging an IP Address LeetCode Solution125
1067Validate Binary Search Tree125
1068Count minimum steps to get the given desired array125
1069Bitwise AND of Numbers Range LeetCode Solution125
1070Number of Closed Islands Leetcode Solution124
1071Super Ugly Number124
1072Remove Duplicates from Sorted Array II Leetcode Solution124
1073Rearrange array such that even index elements are smaller and odd index elements are greater124
1074Binary Tree Data Structure124
1075Largest BST Subtree LeetCode Solution124
1076Binary Tree Right Side View LeetCode Solution124
1077Divisible Pairs Counting124
1078Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution124
1079Employee Importance LeetCode Solution124
1080Recover Binary Search Tree Leetcode Solution124
1081Subarrays with K Different Integers Leetcode Solution123
1082Print all triplets in sorted array that form AP123
1083Serialize and Deserialize Binary Tree LeetCode Solution123
1084Generate Parentheses Leetcode Solution123
1085Day of the Year Leetcode Solution123
1086Print Next Greater Number of Q queries123
1087Consecutive Characters LeetCode Solution123
1088Count pairs from two sorted arrays whose sum is equal to a given value x123
1089Populating Next Right Pointers in Each Node Leetcode Solution123
1090Find Smallest Range Containing Elements from k Lists123
1091Maximum difference between frequency of two elements such that element having greater frequency is also greater123
1092Types of Binary Tree123
1093Clone a Binary Tree with Random Pointers123
1094Number of Students Doing Homework at a Given Time Leetcode Solution122
1095Longest Bitonic Subsequence122
1096Root to Leaf path with target sum Leetcode Solutions122
1097Search in Sorted Rotated Array122
1098Smallest Common Region Leetcode Solution122
1099Number of siblings of a given Node in n-ary Tree122
1100Remove Palindromic Subsequences Leetcode Solution122
1101Path Sum122
1102Combination Sum IV LeetCode Solution121
1103Print Right View of a Binary Tree121
1104Write Code to Determine if Two Trees are Identical121
1105Kth Smallest Product of Two Sorted Arrays LeetCode Solution121
1106Constant time range add operation on an array121
1107Bottom View of a Binary Tree121
1108Third Maximum Number Leetcode Solution121
1109Remove duplicates from sorted array121
1110Valid Tic-Tac-Toe State LeetCode Solution121
1111Level of Each node in a Tree from source node121
1112Convert BST into a Min-Heap without using array121
1113Next Permutation Leetcode Solution121
1114Palindrome Permutation LeetCode Solution120
1115Iterative method to find ancestors of a given binary tree120
1116Minimum sum of squares of character counts in a given string after removing k characters120
1117Find Three Element From Different Three Arrays Such That a + b + c = sum120
1118Search Insert Position120
1119Products of ranges in an array120
1120Find maximum difference between nearest left and right smaller elements120
1121Distinct Subsequences120
1122Increasing Triplet Subsequence LeetCode Solution119
1123Mean of Array After Removing Some Elements Leetcode Solution119
1124Print modified array after executing the commands of addition and subtraction119
1125Prime Palindrome LeetCode Solution119
1126Topological Sorting119
1127Minimum Score Triangulation of Polygon Leetcode Solution119
1128Maximum Product Subarray119
1129Count Largest Group Leetcode Solution119
1130Maximum Binary Tree119
1131Thousand Separator Leetcode Solution119
1132Cutting a Rod119
1133Longest Increasing Consecutive Subsequence119
1134Golomb sequence118
1135Reformat The String Leetcode Solution118
1136Moser-de Bruijn Sequence118
1137Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution118
1138Construct K Palindrome Strings LeetCode Solution118
1139Cells with Odd Values in a Matrix LeetCode Solution118
1140Search an Element in Sorted Rotated Array118
1141Red-Black Tree Introduction117
1142K maximum sums of overlapping contiguous sub-arrays117
1143Longest Subarray of 1’s After Deleting One Element LeetCode Solution117
1144Kth Smallest Number in Multiplication Table Leetcode Solution117
1145Minimum Absolute Difference in BST Leetcode Solution117
1146Transform a BST to Greater sum Tree117
1147Sum of Even Numbers After Queries117
1148Binary Tree to Binary Search Tree Conversion117
1149Queries for Number of Distinct Elements in a Subarray117
1150Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution117
1151Swap Nodes In Pairs117
1152Possible Bipartition LeetCode Solution116
1153Count even length binary sequences with same sum of first and second half bits116
1154Factorial Trailing Zeroes LeetCode Solution116
1155Find maximum length Snake sequence116
1156Longest Repeated Subsequence116
1157Palindromic Substrings Leetcode Solution116
1158Maximum Product of Splitted Binary Tree LeetCode Solution116
1159K’th Largest element in BST using constant extra space116
1160Priority Queue116
1161Rotate Array116
1162Check Array Formation Through Concatenation Leetcode Solution116
1163Subset Sum Problem in O(sum) space116
1164Merge two BSTs with limited extra space116
1165Maximize sum of consecutive differences in a circular array116
1166Delete Nodes and Return Forest Leetcode Solution116
1167Bus Routes Leetcode Solution115
1168Web Crawler LeetCode Solution115
1169First Bad Version115
1170Compare Strings by Frequency of the Smallest Character Leetcode Solution115
1171Find the smallest binary digit multiple of given number115
1172Decision Tree115
1173Closest Binary Search Tree Value Leetcode Solution114
1174Count Pairs Whose Products Exist in Array114
1175Find a sorted subsequence of size 3 in linear time114
1176Minimum Sideway Jumps LeetCode Solution114
1177Minimum Moves to Equal Array Elements LeetCode Solution114
1178Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution114
1179Search Suggestions System LeetCode Solution114
1180Diameter of N-Ary Tree LeetCode Solution113
1181Reverse a Path in BST using Queue113
1182Number of Orders in the Backlog Leetcode Solution113
1183Minimum Cost to Move Chips to The Same Position LeetCode Solution113
1184Given a binary tree, how do you remove all the half nodes?113
1185Maximum number of segments of lengths a, b and c113
1186Queue Reconstruction by Height112
1187Find Largest Value in Each Tree Row LeetCode Solution112
1188Matchsticks to Square Leetcode Solution112
1189Decrease Elements To Make Array Zigzag LeetCode Solution112
1190Lowest Common Ancestor in Binary Search Tree112
1191Contiguous Array LeetCode Solution112
1192Swapping Nodes in a Linked List Leetcode Solution112
1193Closest Leaf in a Binary Tree LeetCode Solution111
1194Reformat Date LeetCode Solution111
1195Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution111
1196Moving Stones Until Consecutive Leetcode Solution111
1197Convert Sorted Array to Binary Search Tree LeetCode Solutions111
1198Array Queries for multiply replacements and product111
1199Champagne Tower LeetCode Solution111
1200Sum of Left Leaves LeetCode Solution110
1201Maximum Value at a Given Index in a Bounded Array LeetCode Solution110
1202Valid Perfect Square LeetCode Solution110
1203Integer Break LeetCode Solution110
1204Maximum sum of pairs with specific difference110
1205Valid Triangle Number110
1206Maximum sum bitonic subarray110
1207Graph and its representation110
1208How to print maximum number of A’s using given four keys110
1209New 21 Game110
1210Range Sum Query using Sparse Table110
1211Replace two consecutive equal values with one greater110
1212Range Queries for Longest Correct Bracket Subsequence109
1213Arithmetic Slices II – Subsequence LeetCode Solution109
1214Maximum Depth Of Binary Tree109
1215Write a function to get the intersection point of two Linked Lists109
1216Concatenation of Array LeetCode Solution109
1217BST to a Tree with Sum of all Smaller Keys109
1218Guess The Word109
1219The kth Factor of n Leetcode Solution109
1220Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution109
1221Path Crossing Leetcode Solution109
1222Kth Smallest Element in a BST109
1223Print modified array after multiple array range increment operations109
1224Maximum sum of a path in a Right Number Triangle108
1225Check if each internal node of a BST has exactly one child108
1226Merge Sort108
1227Queries on Probability of Even or Odd Number in given Ranges108
1228Minimum Swaps To Make Sequences Increasing LeetCode Solution108
1229Divide Two Integers Leetcode Solution108
1230Design Skiplist LeetCode Solution108
1231Lowest Common Ancestor of a Binary Tree Leetcode Solution108
1232Power of Two107
1233Check Completeness of a Binary Tree LeetCode Solution107
1234Sliding Window Median Leetcode Solution107
1235Graph Cloning107
1236Count Subsets Having Distinct Even Numbers107
1237Longest Common Prefix Using Word by Word Matching107
1238Perfect Squares LeetCode Solution107
1239Flatten 2D Vector LeetCode Solution107
1240Check for Identical BSTs without building the trees107
1241Check if all levels of two Binary Tree are anagrams or not107
1242Print n terms of Newman-Conway Sequence106
1243Maximum Array from Two given Arrays Keeping Order Same106
1244LRU Cache Leetcode Solution106
1245Maximize Elements Using Another Array106
1246Find minimum number of merge operations to make an array palindrome106
1247Count and Toggle Queries on a Binary Array106
1248Symmetric Tree LeetCode Solution Leetcode Solution106
1249Largest Plus Sign Leetcode Solution106
1250Find k-th smallest element in BST (Order Statistics in BST)105
1251Contiguous Array105
1252Bold Words in String LeetCode Solution105
1253Mean of range in array105
1254Find Minimum in Rotated Sorted Array II LeetCode Solution105
1255Missing Number105
1256Next greater element104
1257Verify Preorder Serialization of a Binary Tree104
1258Merge k Sorted Lists Leetcode Solution103
1259Parallel Courses II LeetCode Solution103
1260Maximum Product Subarray103
1261Excel Sheet Column Title LeetCode Solution103
1262Image Overlap LeetCode Solution103
1263Print Ancestors of a Given Binary Tree Node Without Recursion103
1264Minimum Remove to Make Valid Parentheses LeetCode Solution103
1265Check If a String Can Break Another String Leetcode Solution103
1266Smallest Range II Leetcode Solution102
1267Check if two nodes are on the same path in a Tree102
1268Palindrome Partitioning101
1269Minimum Time to Collect All Apples in a Tree LeetCode Solution101
1270Check in binary array the number represented by a subarray is odd or even101
1271Orderly Queue LeetCode Solution101
1272Koko Eating Bananas LeetCode Solution100
1273Check if X can give change to every person in the Queue99
1274Merge Sorted Array99
1275Newman–Shanks–Williams prime98
1276Min Cost Climbing Stairs LeetCode Solution98
1277Number of elements less than or equal to a given number in a given subarray98
1278Different Ways to Add Parentheses Leetcode Solution98
1279Peeking Iterator LeetCode Solution98
1280Maximum Sum Increasing Subsequence97
1281Largest Submatrix With Rearrangements LeetCode Solution97
1282Queries for Decimal Values of Subarrays of a Binary Array96
1283Find maximum average subarray of k length96
1284Range Minimum Query (Square Root Decomposition and Sparse Table)96
1285Longest Substring Without Repeating Characters Leetcode Solution95
1286Number of indexes with equal elements in given range95
1287Check given array of size n can represent BST of n levels or not94
1288Array Nesting Leetcode Solution93
1289Maximum product of an increasing subsequence93
1290Binary Tree to Binary Search Tree Conversion using STL set93
1291Minimum Number of People to Teach LeetCode Solution92
1292Arranging Coins Leetcode Solution92
1293Random Pick Index LeetCode Solution91
1294Find the Winner of the Circular Game LeetCode Solution91
1295Minimum Total Space Wasted With K Resizing Operations LeetCode Solution91
1296Encoded String With Shortest Length LeetCode Solution91
1297Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution90
1298Queries on XOR of greatest odd divisor of the range90
1299Reach a Number LeetCode Solution90
1300Convert a BST to a Binary Tree such that sum of all greater keys is added to every key90
1301Convert to Base -2 LeetCode Solution89
1302Jump Game IV LeetCode Solution89
1303Insert Delete GetRandom O(1) Leetcode Solution88
1304Palindrome Number LeetCode Solution86
1305Vertical Order Traversal of Binary Tree LeetCode Solution86
1306Add Two Numbers II Leetcode Solution86
1307Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution84
1308Design Underground System Leetcode Solution83
1309Print Maximum Length Chain of Pairs83
1310Continuous Subarray Sum LeetCode Solution82
1311Detect Capital Leetcode Solution81
1312Design A Leaderboard Leetcode Solution78
1313Substring with Concatenation of All Words Leetcode Solution76
1314Minimum Swaps to Group All 1’s Together Leetcode Solution75
1315Top K Frequent Elements LeetCode Solution72
1316Minimum Path Sum Leetcode Solution72
1317Odd Even Linked List Leetcode Solution72
1318Shifting Letters LeetCode Solution71
1319Maximum Population Year LeetCode Solution70
1320Binary Tree Inorder Traversal LeetCode Solution70
1321Decode String Leetcode Solution70
1322Count Sub Islands LeetCode Solution69
1323Shortest Unsorted Continuous Subarray LeetCode Solution69
1324Find the Town Judge LeetCode Solution69
1325Longest Common Subsequence LeetCode Solution68
1326Best Meeting Point LeetCode Solution68
1327Sum Root to Leaf Numbers LeetCode Solution67
1328Find the Town Judge LeetCode Solution66
1329Design Add and Search Words Data Structure LeetCode Solution65
1330Rectangle Overlap LeetCode Solution63
1331Maximum Population Year LeetCode Solution62
1332Insert into a Sorted Circular Linked List LeetCode Solution61
1333Stone Game IV LeetCode Solution60
1334Score of Parenthesis LeetCode Solution60
1335Range Sum Query 2D – Immutable LeetCode Solution59
1336Flatten Binary Tree to Linked List LeetCode Solution59
1337Valid Triangle Number LeetCode Solution58
1338Is Graph Bipartite? LeetCode Solution57
1339Reveal Cards In Increasing Order Leetcode Solution52
1340Divide Chocolate LeetCode Solution48
1341Range Sum of BST LeetCode Solution40
1342Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution38
1343Reverse Integer Leetcode Solution37
1344Sort Colors LeetCode Solution36
1345Find K Closest Elements LeetCode Solution33
1346Rotate String LeetCode Solution30
1347Excel Sheet Column Number LeetCode Solution29
1348Maximum Side Length of a Square with Sum Less than or Equal to Threshold LeetCode Solution28
Translate »