Reverse Integer Leetcode Solution

Difficulty Level Medium
Frequently asked in Adobe Amazon Apple Bloomberg ByteDance Cognizant Facebook Google Infosys Intel JP Morgan Microsoft Oracle Samsung Uber Visa VMware YahooViews 36

Problem Statement

Reverse Integer LeetCode Solution says that – Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.

Assume the environment does not allow you to store 64-bit integers (signed or unsigned).

Example 1:

Input:

 x = 123

Output:

 321

Example 2:

Input:

 x = -123

Output:

 -321

Example 3:

Input:

 x = 120

Output:

 21

 

Constraints:

  • -231 <= x <= 231 - 1

 

Algorithm:

Idea:

  • In order to solve this question, What we will do in this question, At first we will reverse the given integer by breaking the given Integer and After that, We will check if the reverse integer lies within the range of [-2**31,2**31]. Then we will return the reverse integer else if the reverse integer exceeds the range then we will return 0 and obviously we have to focus on the negative integers also if the number is negative then we will use abs function and do the same and at the time of return, we will return negative symbol with the reverse Integer.

Approach:

  • First, we will make one variable total and copy the given integer in the k variable and one symbol variable that is equal to 1.
  •  Then we will check if number is negative then update number  = abs(number) and update symbol = -1.
  • After that, we will use the while conditioning and within that condition, we break the given integer by making one variable b = x%10 and update total = total*10+ b and will update x = x//10.
  • At last, we will check if total > 2**31 then we will return 0 else return total*symbol.

Image of Reverse Integer Leetcode Solution –

Reverse Integer Leetcode SolutionPin

class Solution:
    def reverse(self, x: int) -> int:
        total = 0
        symbol = 1
        k = x
        
        if k < 0:
            x = abs(x)
            symbol = -1
            
        while(x > 0):
            b = x % 10
            total = total*10 + b
            
            x = x//10
        
        if total > pow(2,31):
            return 0
        
        else:
            return total*symbol
        
class Solution {
    public int reverse(int x) {
        if (x >= -9 && x <= 9) {
            return x;
        }
        if (x == Integer.MIN_VALUE || x == Integer.MAX_VALUE) {
            return 0;
        }

        int symbol = x < 0 ? -1 : 1;
        x = Math.abs(x);
        int total = 0;

        while (x > 0) {
            int digit = x % 10;
            if (total > Integer.MAX_VALUE / 10
                    || (total == Integer.MAX_VALUE / 10 && digit > Integer.MAX_VALUE % 10)) {
                return 0;
            }
            total = total * 10 + digit;
            x /= 10;
        }

        return symbol * total;
    }
}

TIME COMPLEXITY: O(N)

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

SIMILAR QUESTION: https://leetcode.com/problems/string-to-integer-atoi/

– https://leetcode.com/problems/reverse-bits/

https://www.tutorialcup.com/interview/stack/reverse-a-number-using-stack.htm

 

 

 

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 II990
38Find the second most frequent character983
39Given a string find its first non-repeating character962
40Find Triplet in Array With a Given Sum961
41Given a sorted array and a number x, find the pair in array whose sum is closest to x950
42Total number of occurrences of a given item in the linked list950
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
58Rotate a Linked List788
59Count of Triplets With Sum Less than Given Value788
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
78A Product Array Puzzle681
79Addition of Two Matrices681
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
90Form Minimum Number from Given Sequence of D’s and I’s620
91Divide a string in N equal parts620
92Online Algorithm for Checking Palindrome in a Stream620
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
97Find the Minimum Element in a Sorted and Rotated Array603
98Sort a stack using a temporary stack603
99Move last element of the Linked List at first place600
100First Circular Tour to Visit all the Petrol Bunks596
101Subarray and Subsequence596
102Largest Subarray with Equal Number of 0’s and 1’s592
103Flattening a linked list589
104Compare two strings(linked lists)589
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
115Remove all duplicates in a sorted linked list561
116Minimum Characters to be Added at Front to Make String Palindrome561
117Rearrange a given linked list in-place561
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
130Remove Extra Spaces from a String518
131Removing Spaces from a String using stringstream518
132Check if a given string is a rotation of a palindrome515
133Partition Problem514
134Smallest Palindrome after Replacement514
135Remove duplicates from a string513
136Longest Palindrome can be Formed by Removing or Rearranging Characters511
137Maximum Sum Increasing Subsequence511
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
141Length of Longest valid Substring497
142Insert Node in the Sorted Linked List497
143Delete Last Occurrence494
1443Sum Leetcode Solution494
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 if all Rows of a Matrix are Circular Rotations of Each Other468
154Check length of a String is Equal to the Number Appended at its Last468
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
160Find the Subarray of given length with Least Average452
161Compare Two Version Numbers452
162Merge two sorted linked lists such that merged list is in reverse order452
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
169Find Element Using Binary Search in Sorted Array430
170Swap Kth Node from beginning with Kth Node from End430
171Find K Length Subarray of Maximum Average430
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
189Rearrange a linked list in Zig-Zag376
190Kth Non-repeating Character376
191Caesar Cipher375
192Check if String can Become Empty by Recursively Deleting given Substring374
193Pancake Sorting373
194Rotate Image by 90 degrees369
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 Given352
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
210Minimum Characters to be Removed to Make a Binary String Alternate338
211Split a string338
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
223Binary Tree to Doubly linked list321
224Print Shortest Path to Print a String on Screen320
225Can we reverse a linked list in less than O(n) time ?320
226Nth Character in Concatenated Decimal String316
227Convert string1 to string2 in one edit316
228Reverse a String using Stack316
229Sort Elements by Frequency II316
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
238Longest Common Subsequence with Permutations298
239Count the Pairs at Same Distance as in English Alphabets298
240Next Greater Element in an Array294
241Matrix Chain Multiplication using Dynamic Programming292
242Palindrome Permutation287
243Find Nth Node283
244Searching a node in a Binary Search Tree283
245Find All Pairs With a Given Difference281
246Triplet from three linked lists with given sum280
247Delete a Tree279
248Roman to Integer Leetcode Solution279
249String(represents an integer) to value275
250Print all Possible Ways to Break a String in Bracket Form275
251Reverse a String275
252Reverse Bits271
253Binary Tree271
254Change Gender of a given String270
255Delete a node under given conditions270
256Word Search Leetcode Solution268
257Sort an array of strings268
258How to Efficiently Implement k Stacks in a Single Array?265
259Number of sub-strings which recursively add up to 9265
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
269Move all negative elements to one side of array257
270Repeated Substring Pattern257
271Min Stack255
272N queen problem253
273Number of Islands LeetCode Solution249
274Find, second, frequent, character249
275Dijkstra Algorithm248
276House Robber Leetcode Solution247
277Cuckoo sequence program247
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
283Search Insert Position Leetcode Solution242
284Expression Evaluation242
285Fibonacci numbers240
286Valid Palindrome Leetcode Solution238
287Plus One Leetcode Solution237
288How to Delete a Linked List237
289KMP Algorithm237
290Sudoku Solver236
291Min Stack Leetcode Solution236
292Word Search235
293Reverse words in a string234
294Evaluation of Postfix Expression233
295Subset Leetcode233
296Combination Sum Leetcode Solution232
297Number Of 1 bits232
298Backspace String Compare227
299Rabin Karp Algorithm226
300Merge Sorted Arrays Leetcode Solution226
301Pair of Positive Negative Values in an Array226
302Set Matrix Zeroes224
303Sqrt(x) Leetcode Solution224
304Contains Duplicate II Leetcode Solution223
305Reversing a Queue223
306Tower Of Hanoi222
307Subarray with 0 sum221
308Combination Sum220
309Common elements in all rows of a given matrix219
310Product of array except self219
311Integer to Roman Leetcode Solution217
312Intersection of Two Arrays II Leetcode Solution217
313Count subarrays with equal number of 1’s and 0’s216
314Delete middle element of a stack215
315Pascal Triangle Leetcode215
316String Compression215
317Reverse individual words214
318Construct Binary Tree from Given Inorder and Preorder Traversals213
319Find Top K (or Most Frequent) Numbers in a Stream213
320Second Most Repeated Word in a Sequence212
321Sliding Window Technique212
322Minimum swaps required to bring all elements less than or equal to k together212
323Segregate even and odd numbers211
324Add Binary Leetcode Solution211
325Bellman Ford Algorithm211
326Pow(x, n) 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 array209
333Single Number Leetcode Solution209
334Kruskal Algorithm209
335Contains Duplicate208
336Postfix to Infix Conversion208
337Find sum of non-repeating elements (distinct) elements in an array208
338Minimum Value to Get Positive Step by Step Sum Leetcode Solution207
339Design a stack that supports getMin() in O(1) time and O(1) extra space207
340K-th Smallest Element in a Sorted Matrix207
341Count Odd Numbers in an Interval Range Leetcode Solution206
342Maximum Number of Balloons Leetcode Solution206
343Sort elements by frequency206
344Maximum Subarray205
345Group Words With Same Set of Characters204
346Third Maximum Number Leetcode Solution204
347Longest Common Prefix Leetcode Solution204
348Permutations Leetcode Solution204
349Top K Frequent Words203
350Majority Element Leetcode Solution203
351Convex Hull Algorithm203
352Find Numbers with Even Number of Digits Leetcode Solution203
353Longest Substring Without Repeating Characters LeetCode Solution202
354Find Lucky Integer in an Array Leetcode Solution202
355Spiral Matrix LeetCode Solution202
356Swap Nodes in Pairs Leetcode Solutions202
357Sum of minimum and maximum elements of all subarrays of size k201
358Minimum operation to make all elements equal in array201
359Sorting array using Stacks201
360Find the Town Judge Leetcode Solution200
361Evaluate Division200
362Count subarrays having total distinct elements same as original array200
363Scramble String200
364Smallest Subarray with k Distinct Numbers200
365Merge Two Sorted Lists Leetcode Solutions198
366Special Number198
367First element occurring k times in an array197
368Check if two arrays are equal or not197
369Reverse a Number Using Stack197
370Prefix to Infix Conversion196
371Given two unsorted arrays find all pairs whose sum is x196
372Minimum Path Sum196
373Search in Rotated Sorted Array Leetcode Solution196
374Group Anagrams196
375Number of Good Pairs Leetcode Solution195
376Best Time to Buy and Sell Stock  II Leetcode Solution195
377Pascal’s Triangle II Leetcode Solution195
378Count Primes Leetcode Solutions195
379Reversing the First K elements of a Queue194
380Huffman Coding194
381Find duplicates in a given array when elements are not limited to a range194
382Maximum Distance Between two Occurrences of Same Element in Array194
383Minimum Absolute Difference Leetcode Solution193
384Single Number193
385Power of Two 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
400Max Consecutive Ones Leetcode Solution189
401Matrix Diagonal Sum Leetcode Solution189
402How Many Numbers Are Smaller Than the Current Number Leetcode Solution189
403Unique Paths Leetcode Solution189
404Subarray Sum Equals K LeetCode Solution189
405Sorting using trivial hash function189
406Expression Contains Redundant Bracket or Not188
407Unique Paths188
408Leetcode Permutations188
409Decode String188
410Palindrome Substring Queries188
411Zigzag Conversion188
412Fibonacci Number LeetCode Solution187
413Find Winner on a Tic Tac Toe Game Leetcode Solution187
414Happy Number Leetcode Solution187
415Subarray Sum Equals k187
416Check if Array Contains Contiguous Integers With Duplicates Allowed187
417Find The Duplicate Number187
418Subset sum problem187
419Difference between highest and least frequencies in an array187
420Smallest Element Repeated Exactly K Times187
421Sort Integers by The Number of 1 Bit Leetcode Solution187
422Subtract the Product and Sum of Digits of an Integer Leetcode Solution187
423Monotonic Array LeetCode Solution186
424Find the Closest Palindrome number186
425Cumulative Frequency of Count of Each Element in an Unsorted Array186
426Convert String To Int186
427Reverse Integer186
428Reverse Vowels of a String Leetcode Solution186
429Letter Case Permutation186
430Print All Distinct Elements of a Given Integer Array185
431Find Number of Employees Under every Employee185
432Shuffle the Array Leetcode Solution185
433Length of the largest subarray with contiguous elements185
434Find top three repeated in array185
435Check If N and Its Double Exist Leetcode Solution185
436Nth Catalan Number185
437Remove Duplicates from Sorted Array Leetcode Solution185
438Capacity To Ship Packages Within D Days Leetcode Solution184
439Bipartite Graph184
440Sort a stack using recursion184
441Trapping Rain Water Leetcode Solution184
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
487Text Justification LeetCode Solution177
488Longest Common Prefix using Trie177
489Number of Steps to Reduce a Number to Zero Leetcode Solution177
490Excel Sheet Column Number Leetcode Solution177
491Multiply Strings Leetcode Solution177
492Floyd Warshall Algorithm177
493Merge Overlapping Intervals176
494Top View of Binary Tree176
495Balanced Binary Tree Leetcode Solution176
496Priority Queue in C++176
497Iterative Tower of Hanoi176
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
504Move Zeroes LeetCode Solution174
505Valid Parenthesis String174
506Check if a given array contains duplicate elements within k distance from each other174
507Peak Index in a Mountain Array174
508Max Area of Island174
509Prefix to Postfix Conversion174
510Count and Say Leetcode Solution174
511Postfix to Prefix Conversion174
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
601Summary Ranges Leetcode Solution163
602Minimum number of subsets with distinct elements163
603Find minimum difference between any two elements163
604Rotate Image LeetCode Solution163
605Minimum insertions to form a palindrome with permutations allowed162
606Printing brackets in Matrix Chain Multiplication Problem162
607Word Pattern162
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
685Subset Sum Leetcode154
686Maximum Number of Occurrences of a Substring Leetcode Solution154
687Path With Maximum Minimum Value LeetCode Solution154
688Ugly Number Leetcode Solution154
689Lucky Numbers in a Matrix Leetcode Solution154
690To Lower Case Leetcode Solution154
691Reducing Dishes LeetCode Solution154
692Find the Smallest Divisor given a Threshold Leetcode Solution153
693Number of Dice Rolls With Target Sum LeetCode Solution153
694Find Leaves of Binary Tree LeetCode Solution153
695Majority Element II Leetcode Solution153
696Find the node with minimum value in a Binary Search Tree153
697Sort Array by Increasing Frequency Leetcode Solution153
698Valid Palindrome153
699Longest Increasing Path in a Matrix LeetCode Solution153
700Find whether an array is subset of another array153
701Reversing a Queue using Recursion153
702Hamming Distance Leetcode Solution153
703Maximum Product of Three Numbers LeetCode Solution153
704Print the Fibonacci numbers in reverse order153
705Delete Nth node from the end of the given linked list152
706Add and Search Word – Data structure design LeetCode152
707Dynamic Programming Basics152
708Remove Invalid Parentheses Leetcode Solution152
709Valid Perfect Square Leetcode Solution152
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
713Unique Paths II Leetcode Solution152
714Partition Array Into Three Parts With Equal Sum Leetcode Solution152
715Reverse Only Letters LeetCode Solution152
716Recover Binary Search Tree152
717Factorial Trailing Zeroes Leetcode Solution152
718Longest Span with same Sum in two Binary arrays151
719Binary Tree zigzag level order Traversal151
720Edit Distance LeetCode Solution151
721Decompress Run-Length Encoded List Leetcode Solution151
722Largest subarray with equal number of 0s and 1s151
723Convert a Number to Hexadecimal Leetcode Solution151
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
729Best Meeting Point LeetCode Solution149
730Merge Two Binary Trees LeetCode Solution149
731Find Pair with Greatest Product in Array149
732Symmetric Tree Leetcode Solution149
733Rank Transform of an Array Leetcode Solution149
734Stack Permutations (Check if an array is stack permutation of other)149
735Merge K Sorted Linked Lists149
736Bubble sort using two Stacks149
737Maximum 69 Number Leetcode Solution149
738Minimum Distance Between BST Nodes Leetcode Solution149
739Keyboard Row Leetcode Solution149
740Minimum Height Trees149
741Finding K closest element149
742Find the largest multiple of 3149
743Find Maximum Depth of Nested Parenthesis in a String149
744Find unique character in a string149
745Morris Traversal148
746Binary Tree Maximum Path Sum LeetCode Solution148
747Remove brackets from an algebraic string containing + and – operators148
748Elements to be added so that all elements of a range are present in array148
749Jump Game148
750Growable array based stack148
751Invert Binary Tree LeetCode Solution148
752Perform String Shifts Leetcode148
753Robot Room Cleaner Leetcode Solution148
754Generate all possible sorted arrays from alternate elements of two given sorted arrays148
755Word Pattern LeetCode Solution148
756Race Car LeetCode Solution148
757Sorted Linked List to Balanced BST148
758Bulb Switcher LeetCode Solution148
759Minimum time required to rot all oranges147
760Maximum Depth of N-ary Tree Leetcode Solution147
761Non-decreasing Array LeetCode Solution147
762Program for Bridge and Torch problem147
763Evaluate Reverse Polish Notation LeetCode Solution147
764Kth ancestor of a node in binary tree147
765Find All Duplicates in an Array LeetCode Solution147
766Count quadruples from four sorted arrays whose sum is equal to a given value x147
767First Unique Character in a String LeetCode Solution147
768Student Attendance Record I Leetcode Solution147
769Queue based approach for first non-repeating character in a stream147
770Largest rectangular sub-matrix whose sum is 0147
771k-th missing element in increasing sequence which is not present in a given sequence147
772Number of NGEs to the Right147
773Diagonal Traversal of Binary Tree147
774Relative Ranks Leetcode Solution146
775Merge Sorted Array LeetCode Solution146
776Number of Islands II LeetCode Solution146
777Remove Duplicates from Sorted List LeetCode Solution146
778Maximum Length of a Concatenated String with Unique Characters Leetcode Solution146
779Valid Number146
780Search in a Binary Search Tree Leetcode Solution146
781Nested List Weight Sum II LeetCode Solution146
782Check for Palindrome after every character replacement Query146
783Snakes and Ladders LeetCode Solution146
784N-Queens LeetCode Solution146
785Remove Nth Node From End of List Leetcode Solution146
786Largest Rectangle in Histogram LeetCode Solution146
787Tiling Problem146
788String comparison containing wildcards146
789Minimum number of jumps to reach end146
790String Compression LeetCode Solution146
791Sort an array according to the order defined by another array145
792Count items common to both the lists but with different prices145
793Search a 2D Matrix II Leetcode Solution145
794Interval Tree145
795Maximum Difference Between Increasing Elements LeetCode Solution145
796Find if Path Exists in Graph Leetcode Solution145
797Base 7 Leetcode Solution145
798Minimize Maximum Pair Sum in Array LeetCode Solution145
799Linked List Cycle145
800Partition to K Equal Sum Subsets Leetcode Solution145
801Special Array With X Elements Greater Than or Equal X Leetcode Solution145
802Minimum swaps to make sequences increasing145
803Find Median from Data Stream LeetCode Solution145
804Check If Array Pairs Are Divisible by k LeetCode Solution144
805Split a String in Balanced Strings Leetcode Solution144
806Circular Queue144
807Print a Binary Tree in Vertical Order144
808Check if Two Expressions With Brackets are Same144
809Final Prices With a Special Discount in a Shop Leetcode Solution144
810Number Complement Leetcode Solution144
811Crawler Log Folder Leetcode Solution144
812A Space Optimized DP solution for 0-1 Knapsack Problem144
813Alien Dictionary LeetCode Solution144
814Transpose Graph144
815Reorder Data in Log Files LeetCode Solution144
816Clone Graph LeetCode Solution143
817One Edit Distance LeetCode Solution143
818Iterative Preorder Traversal143
819Get Maximum in Generated Array Leetcode Solution143
820Nearest Exit from Entrance in Maze LeetCode Solution143
821Find all triplets with zero sum143
822Total Numbers With no Repeated Digits in a Range143
823Convert BST to Min Heap143
824Minimum Time Visiting All Points Leetcode Solution143
825Remove Duplicates from Sorted List II143
826Course Schedule II – LeetCode143
827Permutation Coefficient143
828Priority Queue using doubly linked list143
829Longest Subarray Having Count of 1s One More than Count of 0s143
830Sort Colors142
831Maximum size subarray sum equals k142
832Maximum Nesting Depth of the Parentheses Leetcode Solution142
833Guess Number Higher or Lower LeetCode Solution142
834Top K Frequent Words LeetCode Solution142
835Design a Stack With Increment Operation Leetcode Solution142
836Partition List Leetcode Solution142
837Find the Only Repetitive Element Between 1 to N-1142
838Sort Array By Parity II Leetcode Solution142
839Path with maximum average value142
840Find the subarray with least average142
841Last Stone Weight II LeetCode Solution142
842Minimum Swaps to Make Strings Equal Leetcode Solution142
843Subset with sum divisible by m142
844Given an Array of Pairs Find all Symmetric Pairs in it141
845Check if a given array can represent Preorder Traversal of Binary Search Tree141
846Minimum Jumps to Reach Home LeetCode Solution141
847Check if an Array is Stack Sortable141
848Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution141
849Sum of nearest smaller and greater number141
850Count ways to reach the nth stair using step 1, 2 or 3141
851Friends Pairing Problem141
852Minimum Number of Taps to Open to Water a Garden LeetCode Solution141
853Matrix Chain Multiplication141
854Regular Expression Matching141
855Find All Possible Recipes from Given Supplies LeetCode Solution141
856Count Distinct Elements in Every Window of Size K141
857Brick Wall LeetCode Solution141
858Spiral Matrix II Leetcode Solution141
859Sorted Array to Balanced BST141
860Valid Parentheses Leetcode Solution140
861Subsequence of Size K With the Largest Even Sum LeetCode Solution140
862Check whether a given Binary Tree is Complete or not140
863LCS (Longest Common Subsequence) of three strings140
864Can Place Flowers LeetCode Solution140
865Level order Traversal in Spiral Form140
866Binary Search Tree Search and Insertion140
867Subarray Product Less Than K LeetCode Solution140
868Insert Delete GetRandom140
869Form Minimum Number From Given Sequence140
870Maximum Profit in Job Scheduling Leetcode Solution140
871Tree Traversal (Preorder, Inorder & Postorder)140
872Brightest Position on Street LeetCode Solution140
873Union and Intersection of two Linked Lists139
874Count Subarrays with Same Even and Odd Elements139
875Insert into a Binary Search Tree Leetcode Solution139
876Guess Number Higher or Lower II139
877Rearrange an Array Such that arr[i] is equal to i139
878Find Maximum Sum Possible Equal Sum of Three Stacks139
879Range sum queries without updates139
880Sequences of given length where every element is more than or equal to twice of previous139
881Minimum Sum Path in a Triangle139
882Find all permuted rows of a given row in a matrix139
883Distinct adjacent elements in an array139
884Destination City Leetcode Solution138
885Check if stack elements are pairwise consecutive138
886Count Negative Numbers in a Sorted Matrix LeetCode Solution138
887An Interesting Method to generate Binary Numbers from 1 to n138
888Shortest Word Distance Leetcode Solution138
889Find distance between two nodes of a Binary Tree138
890Identify and Mark Unmatched Parenthesis in an Expression138
891Minimum sum of multiplications of n numbers138
892Missing Element in Sorted Array LeetCode Solution138
893Alien Dictionary138
894BFS for Disconnected Graph138
895Find Common Characters Leetcode Solution138
896Delete And Earn138
897Convert Sorted List to Binary Search Tree138
898Rearrange Spaces Between Words Leetcode Solution138
899A program to check if a binary tree is BST or not138
900Maximum Score After Splitting a String Leetcode Solution138
901Daily Temperatures Leetcode Solution138
902Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution138
903Lemonade Change Leetcode Solution137
904Diagonal Traversal LeetCode Solution137
905Set Matrix Zeroes Leetcode Solution137
906Three way partitioning of an array around a given range137
907Number of Days Between Two Dates LeetCode Solution137
908Construct Complete Binary Tree from its Linked List Representation137
909Check if the given array can represent Level Order Traversal of Binary Search Tree137
9104Sum137
911GCDs of given index ranges in an array137
912Water Bottles Leetcode Solution137
913Repeated Substring Pattern LeetCode Solution137
914Special Positions in a Binary Matrix Leetcode Solution137
915Balanced Expression with Replacement137
916Range LCM Queries137
917Design Browser History LeetCode Solution136
918Number of Equivalent Domino Pairs Leetcode Solution136
919Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i136
920Longest Palindromic Subsequence136
921Queue using Stacks136
922Spiral Matrix III LeetCode Solution136
923Infix to Postfix136
924Diagonal Traverse LeetCode Solution136
925Merge Two Sorted Lists Leetcode136
926Vertical sum in a given binary tree136
927Robot Bounded In Circle LeetCode Solution136
928Least Number of Unique Integers after K Removals Leetcode Solution136
929Construct the Rectangle Leetcode Solution135
930Three Consecutive Odds Leetcode Solution135
931Trim a Binary Search Tree135
932Lexicographical Numbers Leetcode Solution135
933Palindrome Partitioning Leetcode Solution135
934Number of Distinct Islands Leetcode Solution135
935Maximum Subarray Sum Excluding Certain Elements135
936Print Fibonacci sequence using 2 variables135
937Dividing Array into Pairs With Sum Divisible by K135
938K’th Largest Element in BST when modification to BST is not allowed135
939Averages of Levels in Binary Tree135
940Median of Two Sorted Arrays134
941Remove Duplicates from Sorted List II LeetCode Solution134
942Binary array after M range toggle operations134
943Queries for GCD of all numbers of an array except elements in a given range134
944Analyze User Website Visit Pattern LeetCode Solution134
9453 Sum134
946Construct BST from its given Level Order Traversal134
947Merging Intervals134
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
952Pattern Occurrences using Stack134
953Stone Game II Leetcode134
954Strongly Connected Component134
955Time Based Key-Value Store LeetCode Solution134
956Symmetric Tree133
957Create Maximum Number133
958Maximum Frequency Stack Leetcode Solution133
959Newman-Conway Sequence133
960Count Submatrices With All Ones LeetCode Solution133
961Palindrome Partitioning133
962Maximize Sum of Array after K Negations Leetcode Solution133
963Binary Tree Longest Consecutive Sequence LeetCode Solution133
964Iterative Postorder Traversal Using Two Stacks133
965Largest Substring Between Two Equal Characters Leetcode Solution133
966Can Make Arithmetic Progression From Sequence Leetcode Solution133
967Find Maximum of Minimum for Every Window Size in a Given Array132
968Split Array Into Consecutive Subsequences132
969Intersection of Two Linked Lists LeetCode Solution132
970Difference Array | Range update query in O(1)132
971Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space132
972Depth First Search (DFS) for a Graph132
973Sliding Window Maximum132
974My Calendar I LeetCode Solution132
975Sign of the Product of an Array LeetCode Solution132
976Length of Longest Fibonacci Subsequence132
977Maximum Product Subarray132
978Segment Tree132
979Find Duplicate Subtrees131
980Level Order Traversal of Binary Tree131
981Count pair with Given Sum131
982Climbing stairs131
983First missing positive131
984Find the Difference Leetcode Solution131
985Height of a generic tree from parent array131
986Maximum subsequence sum such that no three are consecutive131
987Minimum Height Trees LeetCode Solution131
988Breadth First Search (BFS) for a Graph131
989Binary Search Tree Delete Operation131
990Count Primes in Ranges131
991Reverse Nodes in K-Group130
992Find the First Circular Tour that visits all the Petrol Pumps130
993Minesweeper LeetCode Solution130
994Serialize and Deserialize Binary Tree130
995Insertion in a Binary Tree130
996Find postorder traversal of BST from preorder traversal130
997Double the first element and move zero to end130
998Boundary Traversal of binary tree130
999Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution130
1000Make The String Great Leetcode Solution130
1001Largest Number Leetcode Solution129
1002Partition Equal Subset Sum129
1003Kill Process LeetCode Solution129
1004Kth Smallest Element in a BST Leetcode Solution129
1005Asteroid Collision LeetCode Solution129
1006Product of Array Except Self LeetCode Solution129
1007Count subarrays where second highest lie before highest129
1008The Painter’s Partition Problem129
1009Largest divisible pairs subset129
1010Number Of Longest Increasing Subsequence129
1011Compute nCr % p129
1012Rearrange array such that even positioned are greater than odd129
1013Unique Paths II129
1014Find number of pairs in an array such that their XOR is 0129
1015Maximum Length of Repeated Subarray129
1016Level order traversal using two Queues129
1017Valid Boomerang Leetcode Solution129
1018K Closest Points to Origin Leetcode Solution128
1019Construction of Longest Increasing Subsequence (N log N)128
1020Graph Valid Tree LeetCode Solution128
1021Number of palindromic paths in a matrix128
1022Maximum Number of Ways to Partition an Array LeetCode Solution128
1023Friends Of Appropriate Ages LeetCode Solution128
1024Collect maximum points in a grid using two traversals128
1025Decrypt String from Alphabet to Integer Mapping Leetcode Solution128
1026The Maze III LeetCode Solution128
1027Longest Nice Substring LeetCode Solution128
1028String Matching in an Array Leetcode Solution128
1029Scramble String LeetCode Solution128
1030Binary Search Tree128
1031Shortest Completing Word Leetcode Solution128
1032Design Hit Counter LeetCode Solution127
1033Balanced Binary Tree127
1034Next Greater Element III LeetCode Solution127
1035Find Peak Element127
1036Ugly Numbers127
1037Find whether a subarray is in form of a mountain or not127
1038Boolean Parenthesization Problem127
1039Longest subsequence such that difference between adjacents is one127
1040Invalid Transactions LeetCode Solution127
1041Build an Array With Stack Operations Leetcode Solution127
1042Advantages of BST over Hash Table127
1043Maximum length subsequence with difference between adjacent elements as either 0 or 1127
1044Construct Binary Tree from given Parent Array representation127
1045Available Captures for Rook Leetcode Solution126
1046Minimum Size Subarray Sum126
1047Kth Smallest Element in a Sorted Matrix LeetCode Solution126
1048Minimum Index Sum of Two Lists126
1049Maximum Sum of 3 Non-Overlapping Subarrays126
1050Lowest Common Ancestor126
1051Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’126
1052Add two numbers126
1053Maximum Product of Indexes of Next Greater on Left and Right126
1054Morris Inorder Traversal126
1055Maximum weight transformation of a given string126
1056Implement Trie (Prefix Tree) Leetcode Solution126
1057Ugly Number II LeetCode Solution126
1058Regular Expression Matching Regular Expression Matching LeetCode Solution125
1059Find the minimum distance between two numbers125
1060Path Sum II LeetCode Solution125
1061Validate Binary Search Tree125
1062Maximize Distance to Closest Person LeetCode Solution125
1063Defanging an IP Address LeetCode Solution125
1064Count minimum steps to get the given desired array125
1065Move all negative elements to end in order with extra space allowed125
1066Bitwise AND of Numbers Range LeetCode Solution125
1067Custom Sort String Leetcode Solution125
1068Find a Peak Element II LeetCode Solution125
1069Iterative Depth First Traversal of Graph125
1070Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution124
1071Binary Tree Data Structure124
1072Binary Tree Right Side View LeetCode Solution124
1073Rearrange array such that even index elements are smaller and odd index elements are greater124
1074Number of Closed Islands Leetcode Solution124
1075Remove Duplicates from Sorted Array II Leetcode Solution124
1076Largest BST Subtree LeetCode Solution124
1077Recover Binary Search Tree Leetcode Solution124
1078Divisible Pairs Counting124
1079Super Ugly Number124
1080Employee Importance LeetCode Solution124
1081Serialize and Deserialize Binary Tree LeetCode Solution123
1082Print all triplets in sorted array that form AP123
1083Populating Next Right Pointers in Each Node Leetcode Solution123
1084Types of Binary Tree123
1085Maximum difference between frequency of two elements such that element having greater frequency is also greater123
1086Subarrays with K Different Integers Leetcode Solution123
1087Generate Parentheses Leetcode Solution123
1088Day of the Year Leetcode Solution123
1089Print Next Greater Number of Q queries123
1090Consecutive Characters LeetCode Solution123
1091Clone a Binary Tree with Random Pointers123
1092Count pairs from two sorted arrays whose sum is equal to a given value x123
1093Find Smallest Range Containing Elements from k Lists123
1094Number of Students Doing Homework at a Given Time Leetcode Solution122
1095Smallest Common Region Leetcode Solution122
1096Path Sum122
1097Number of siblings of a given Node in n-ary Tree122
1098Search in Sorted Rotated Array122
1099Longest Bitonic Subsequence122
1100Remove Palindromic Subsequences Leetcode Solution122
1101Write Code to Determine if Two Trees are Identical121
1102Print Right View of a Binary Tree121
1103Bottom View of a Binary Tree121
1104Constant time range add operation on an array121
1105Kth Smallest Product of Two Sorted Arrays LeetCode Solution121
1106Remove duplicates from sorted array121
1107Combination Sum IV LeetCode Solution121
1108Third Maximum Number Leetcode Solution121
1109Convert BST into a Min-Heap without using array121
1110Root to Leaf path with target sum Leetcode Solutions121
1111Valid Tic-Tac-Toe State LeetCode Solution121
1112Next Permutation Leetcode Solution121
1113Level of Each node in a Tree from source node121
1114Search Insert Position120
1115Iterative method to find ancestors of a given binary tree120
1116Find Three Element From Different Three Arrays Such That a + b + c = sum120
1117Distinct Subsequences120
1118Find maximum difference between nearest left and right smaller elements120
1119Palindrome Permutation LeetCode Solution120
1120Minimum sum of squares of character counts in a given string after removing k characters120
1121Products of ranges in an array120
1122Longest Increasing Consecutive Subsequence119
1123Mean of Array After Removing Some Elements Leetcode Solution119
1124Prime Palindrome LeetCode Solution119
1125Minimum Score Triangulation of Polygon Leetcode Solution119
1126Count Largest Group Leetcode Solution119
1127Print modified array after executing the commands of addition and subtraction119
1128Maximum Binary Tree119
1129Thousand Separator Leetcode Solution119
1130Topological Sorting119
1131Maximum Product Subarray119
1132Cutting a Rod119
1133Increasing Triplet Subsequence LeetCode Solution119
1134Reformat The String Leetcode Solution118
1135Search an Element in Sorted Rotated Array118
1136Cells with Odd Values in a Matrix LeetCode Solution118
1137Golomb sequence118
1138Moser-de Bruijn Sequence118
1139Construct K Palindrome Strings LeetCode Solution118
1140Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution118
1141Minimum Absolute Difference in BST Leetcode Solution117
1142Red-Black Tree Introduction117
1143Queries for Number of Distinct Elements in a Subarray117
1144Swap Nodes In Pairs117
1145Kth Smallest Number in Multiplication Table Leetcode Solution117
1146K maximum sums of overlapping contiguous sub-arrays117
1147Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution117
1148Binary Tree to Binary Search Tree Conversion117
1149Transform a BST to Greater sum Tree117
1150Longest Subarray of 1’s After Deleting One Element LeetCode Solution117
1151Sum of Even Numbers After Queries117
1152Possible Bipartition LeetCode Solution116
1153Count even length binary sequences with same sum of first and second half bits116
1154Find maximum length Snake sequence116
1155Longest Repeated Subsequence116
1156K’th Largest element in BST using constant extra space116
1157Subset Sum Problem in O(sum) space116
1158Maximum Product of Splitted Binary Tree LeetCode Solution116
1159Check Array Formation Through Concatenation Leetcode Solution116
1160Merge two BSTs with limited extra space116
1161Priority Queue116
1162Rotate Array116
1163Maximize sum of consecutive differences in a circular array116
1164Palindromic Substrings Leetcode Solution116
1165Delete Nodes and Return Forest Leetcode Solution116
1166Factorial Trailing Zeroes LeetCode Solution116
1167Bus Routes Leetcode Solution115
1168First Bad Version115
1169Decision Tree115
1170Compare Strings by Frequency of the Smallest Character Leetcode Solution115
1171Find the smallest binary digit multiple of given number115
1172Web Crawler LeetCode Solution114
1173Closest Binary Search Tree Value Leetcode Solution114
1174Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution114
1175Search Suggestions System LeetCode Solution114
1176Find a sorted subsequence of size 3 in linear time114
1177Minimum Moves to Equal Array Elements LeetCode Solution114
1178Minimum Sideway Jumps LeetCode Solution114
1179Count Pairs Whose Products Exist in Array114
1180Diameter of N-Ary Tree LeetCode Solution113
1181Maximum number of segments of lengths a, b and c113
1182Number of Orders in the Backlog Leetcode Solution113
1183Reverse a Path in BST using Queue113
1184Minimum Cost to Move Chips to The Same Position LeetCode Solution113
1185Given a binary tree, how do you remove all the half nodes?113
1186Matchsticks to Square Leetcode Solution112
1187Decrease Elements To Make Array Zigzag LeetCode Solution112
1188Queue Reconstruction by Height112
1189Contiguous Array LeetCode Solution112
1190Find Largest Value in Each Tree Row LeetCode Solution112
1191Lowest Common Ancestor in Binary Search Tree112
1192Swapping Nodes in a Linked List Leetcode Solution112
1193Reformat Date LeetCode Solution111
1194Moving Stones Until Consecutive Leetcode Solution111
1195Convert Sorted Array to Binary Search Tree LeetCode Solutions111
1196Champagne Tower LeetCode Solution111
1197Closest Leaf in a Binary Tree LeetCode Solution111
1198Array Queries for multiply replacements and product111
1199Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution111
1200Maximum sum of pairs with specific difference110
1201Maximum sum bitonic subarray110
1202Sum of Left Leaves LeetCode Solution110
1203Range Sum Query using Sparse Table110
1204New 21 Game110
1205Replace two consecutive equal values with one greater110
1206Graph and its representation110
1207Valid Perfect Square LeetCode Solution110
1208How to print maximum number of A’s using given four keys110
1209Integer Break LeetCode Solution110
1210Maximum Value at a Given Index in a Bounded Array LeetCode Solution110
1211Valid Triangle Number110
1212Range Queries for Longest Correct Bracket Subsequence109
1213Path Crossing Leetcode Solution109
1214Maximum Depth Of Binary Tree109
1215Arithmetic Slices II – Subsequence LeetCode Solution109
1216Print modified array after multiple array range increment operations109
1217Write a function to get the intersection point of two Linked Lists109
1218BST to a Tree with Sum of all Smaller Keys109
1219Kth Smallest Element in a BST109
1220Concatenation of Array LeetCode Solution109
1221The kth Factor of n Leetcode Solution109
1222Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution109
1223Guess The Word109
1224Merge Sort108
1225Divide Two Integers Leetcode Solution108
1226Maximum sum of a path in a Right Number Triangle108
1227Minimum Swaps To Make Sequences Increasing LeetCode Solution108
1228Lowest Common Ancestor of a Binary Tree Leetcode Solution108
1229Check if each internal node of a BST has exactly one child108
1230Queries on Probability of Even or Odd Number in given Ranges108
1231Design Skiplist LeetCode Solution108
1232Longest Common Prefix Using Word by Word Matching107
1233Check if all levels of two Binary Tree are anagrams or not107
1234Count Subsets Having Distinct Even Numbers107
1235Power of Two107
1236Check for Identical BSTs without building the trees107
1237Sliding Window Median Leetcode Solution107
1238Flatten 2D Vector LeetCode Solution107
1239Graph Cloning107
1240Check Completeness of a Binary Tree LeetCode Solution107
1241Perfect Squares LeetCode Solution107
1242Print n terms of Newman-Conway Sequence106
1243Count and Toggle Queries on a Binary Array106
1244LRU Cache Leetcode Solution106
1245Maximize Elements Using Another Array106
1246Find minimum number of merge operations to make an array palindrome106
1247Maximum Array from Two given Arrays Keeping Order Same106
1248Symmetric Tree LeetCode Solution Leetcode Solution106
1249Largest Plus Sign Leetcode Solution106
1250Missing Number105
1251Find Minimum in Rotated Sorted Array II LeetCode Solution105
1252Find k-th smallest element in BST (Order Statistics in BST)105
1253Bold Words in String LeetCode Solution105
1254Mean of range in array105
1255Contiguous Array105
1256Next greater element104
1257Verify Preorder Serialization of a Binary Tree104
1258Excel Sheet Column Title LeetCode Solution103
1259Merge k Sorted Lists Leetcode Solution103
1260Parallel Courses II LeetCode Solution103
1261Check If a String Can Break Another String Leetcode Solution103
1262Image Overlap LeetCode Solution103
1263Maximum Product Subarray103
1264Minimum Remove to Make Valid Parentheses LeetCode Solution103
1265Print Ancestors of a Given Binary Tree Node Without Recursion103
1266Smallest Range II Leetcode Solution102
1267Check if two nodes are on the same path in a Tree102
1268Minimum Time to Collect All Apples in a Tree LeetCode Solution101
1269Orderly Queue LeetCode Solution101
1270Check in binary array the number represented by a subarray is odd or even101
1271Palindrome Partitioning101
1272Koko Eating Bananas LeetCode Solution100
1273Merge Sorted Array99
1274Check if X can give change to every person in the Queue99
1275Different Ways to Add Parentheses Leetcode Solution98
1276Min Cost Climbing Stairs LeetCode Solution98
1277Number of elements less than or equal to a given number in a given subarray98
1278Newman–Shanks–Williams prime98
1279Peeking Iterator LeetCode Solution98
1280Largest Submatrix With Rearrangements LeetCode Solution97
1281Maximum Sum Increasing Subsequence97
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
1285Number of indexes with equal elements in given range95
1286Longest Substring Without Repeating Characters Leetcode Solution95
1287Check given array of size n can represent BST of n levels or not94
1288Array Nesting Leetcode Solution93
1289Binary Tree to Binary Search Tree Conversion using STL set93
1290Maximum product of an increasing subsequence93
1291Arranging Coins Leetcode Solution92
1292Minimum Number of People to Teach LeetCode Solution92
1293Find the Winner of the Circular Game LeetCode Solution91
1294Random Pick Index LeetCode Solution91
1295Encoded String With Shortest Length LeetCode Solution91
1296Minimum Total Space Wasted With K Resizing Operations LeetCode Solution91
1297Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution90
1298Convert a BST to a Binary Tree such that sum of all greater keys is added to every key90
1299Reach a Number LeetCode Solution90
1300Queries on XOR of greatest odd divisor of the range90
1301Jump Game IV LeetCode Solution89
1302Convert to Base -2 LeetCode Solution89
1303Insert Delete GetRandom O(1) Leetcode Solution88
1304Palindrome Number LeetCode Solution86
1305Add Two Numbers II Leetcode Solution86
1306Vertical Order Traversal of Binary Tree LeetCode Solution86
1307Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution84
1308Print Maximum Length Chain of Pairs83
1309Design Underground System Leetcode Solution83
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
1316Odd Even Linked List Leetcode Solution72
1317Minimum Path Sum Leetcode Solution72
1318Shifting Letters LeetCode Solution71
1319Binary Tree Inorder Traversal LeetCode Solution70
1320Maximum Population Year LeetCode Solution70
1321Decode String Leetcode Solution70
1322Find the Town Judge LeetCode Solution69
1323Count Sub Islands LeetCode Solution69
1324Shortest Unsorted Continuous Subarray LeetCode Solution69
1325Best Meeting Point LeetCode Solution68
1326Longest Common Subsequence 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
1333Score of Parenthesis LeetCode Solution60
1334Stone Game IV LeetCode Solution60
1335Flatten Binary Tree to Linked List LeetCode Solution59
1336Range Sum Query 2D – Immutable 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
1343Sort Colors LeetCode Solution36
1344Reverse Integer 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 »