Find Peak Element LeetCode Solution


Frequently asked in Adobe Apple Bloomberg ByteDance DE Shaw Facebook Google HRT IXL Microsoft PayPal Roblox Uber VMware Yahoo
categories - Medium Goldmann Sachs tiktok WalmartViews

Problem Statement

Find Peak Element LeetCode Solution says that – A peak element is an element that is strictly greater than its neighbors.

Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks.

You may imagine that nums[-1] = nums[n] = -∞. In other words, an element is always considered to be strictly greater than a neighbor that is outside the array.

You must write an algorithm that runs in O(log n) time.

Example 1:

Input:

 nums = [1,2,3,1]

Output:

 2

Explanation:

 3 is a peak element and your function should return the index number 2.

Example 2:

Input:

 nums = [1,2,1,3,5,6,4]

Output:

 5

Explanation:

 Your function can return either index number 1 where the peak element is 2, or index number 5 where the peak element is 6.

Constraints:

  • 1 <= nums.length <= 1000
  • -231 <= nums[i] <= 231 - 1
  • nums[i] != nums[i + 1] for all valid i.

ALGORITHM –

IDEA –

  • In order to Find Peak elements. First, we will focus on using Binary Search.
  • At first, we will find the middle element and will check that if the middle element is greater than the next element(because we have to focus on the peak and here the peak situation is happening)  then we will update the high = mid.
  • Else we will check for the condition if the middle is smaller than the next element (no peak situation is happening). So basically we will update the low = mid+1.
  • and last we will return to the low.

APPROACH –

  • First, we will use Binary search in this question. we will make variable low = 0 and high = length of nums -1.
  • Then we will use condition while(low < high) and within the condition, we will find the middle.
  • After that, we will check if middle >middle+1 then update the high = mid.
  • Else Update the low = mid+1. This process will run until low is greater than or equal to high.
  • At last, we will return low. Hence we will Find The Peak Element.

Image of  Solution of Find peak –

Find Peak Element LeetCode SolutionPin Find Peak Element LeetCode SolutionPin

class Solution {
    public int findPeakElement(int[] nums) {
        int low = 0;
        int high = nums.length-1;
        
        while(low < high){
            
            int mid = (low+high)/2;
            if(nums[mid] > nums[mid+1]){
                
                high = mid;
                
                
            }
            else
                low = mid+1;
            
            
        }
        return low;
        
        
    }
}
class Solution:
    def findPeakElement(self, nums: List[int]) -> int:
        low = 0
        high = len(nums)-1
        while(low < high):
            mid = (low+high)//2
            
            if nums[mid] > nums[mid+1]:
                high = mid
                
            else:
                low = mid+1
                
        return low

Time Complexity: O(LOGN). For using Binary Search.

Space Complexity: O(1). As we have not taken any Extra Space.

SIMILAR QUESTIONS – https://www.tutorialcup.com/leetcode-solutions/find-a-peak-element-ii-leetcode-solution.htm

Top Interview Questions

S.No Interview Question Number of times has been asked
1Delete a node in doubly linked list2831
2Java program to find the number of Nodes in a Binary Tree2510
3Reverse a string without affecting special characters2470
4Delete a node of a linked list at given position1984
5Palindrome using Recursion1884
6Insert nodes in a linked list in a sorted way (Ascending Order)1669
7Find elements pair from array whose sum equal to number1655
8Sort Elements by Frequency of Occurrences1643
9Quick Sort1627
10Write a program to print all permutations of a given string1615
11Find Minimum Distance Between Two Numbers in an Array1480
12Create a Doubly Linked List1456
13Reverse an Array1417
14Smallest window in a string containing all characters of another string1402
15Find a Triplet That Sum to a Given Value1366
16Recursively remove all adjacent duplicates1363
17First Repeating Element1346
18Arrange Even and Odd number such that Odd comes after Even1328
19Sum of numbers in String1325
20Smallest Positive Number Missing in an Unsorted Array1293
21Check if the Elements of an Array are Consecutive1262
22Detect a loop in the Linked List1247
23Largest Sum Contiguous Subarray1235
24Quick Sort on SIngly Linked List1226
25Subarray with Given Sum1217
26Print all Possible Combinations of R Elements in a given Array of size N1212
27Recursive function to do substring search1208
28Find the Maximum Repeating Number in Array1161
29Binary Tree Level order traversal in Java1132
30Find the First and Second Smallest Elements1126
31Check if two linked lists are identical1113
32Maximum Subarray Sum using Divide and Conquer1111
33Remove characters from first string which are in second1077
34Find Leaders in an Array1066
35Swap nodes in the linked list1044
36Find the Number Occurring Odd Number of Times in an Array1009
37Arrange given Numbers to Form the Biggest Number II999
38Find the second most frequent character998
39Given a string find its first non-repeating character977
40Find Triplet in Array With a Given Sum969
41Total number of occurrences of a given item in the linked list960
42Given a sorted array and a number x, find the pair in array whose sum is closest to x959
43A Program to check if strings are rotations of each other or not958
44Print all possible words from phone digits940
45Find the Missing Number932
46Rearrange Positive and Negative Numbers Alternatively in Array928
47Longest Palindromic Substring911
48Segregate even and odd nodes in a linked list895
49Print Longest common subsequence891
50Union and Intersection of Two Linked Lists880
51Transform one string to another using minimum number of given operations875
52Check rearranged string can form a palindrome857
53Rearrange given Array in Maximum Minimum Form852
54Iterative Implementation of Quick Sort841
55Count Possible Triangles829
56Multiplication of Two Matrices811
57Check if the linked list is palindrome803
58Count of Triplets With Sum Less than Given Value802
59Rotate a Linked List802
60Stock Buy Sell to Maximize Profit797
61Insertion Sort773
62Concatenation of two strings769
63Tug of War767
64Count Number of Substrings with K Distinct Character’s764
65Print all duplicates in the input string762
66Find Nearest Greater and Smaller Element751
67The Celebrity Problem745
68Find Pythagorean Triplets from Array744
69Reverse String Without Temporary Variable739
70Remove ‘b’ and ‘ac’ from a given string739
71Find all Common Elements in Given Three Sorted Arrays735
72Remove all duplicates in an unsorted linked list717
73Find the Row with Maximum Number of 1’s712
74Find the Peak Element from an Array707
75Find the subarray whose sum is equal to a given number X705
76Remove Minimum Characters so that Two Strings Become Anagrams698
77Addition of Two Matrices693
78Find Smallest Missing Number in a Sorted Array691
79A Product Array Puzzle689
80Generate all Binary Strings Without Consecutive 1’s686
81Implement Two Stacks in an Array682
82Maximum Sum of Non Consecutive Elements679
83Maximum Product Subarray II665
84Lexicographic rank of string662
85Check if Two given Matrices are Identical655
86Multiplication of Previous and Next653
87Subtraction of Two Matrices644
88Merge K Sorted Arrays and Print Sorted Output639
89Move All the Zeros to the End of the Given Array638
90Divide a string in N equal parts634
91Online Algorithm for Checking Palindrome in a Stream629
92Form Minimum Number from Given Sequence of D’s and I’s629
93Check whether two strings are anagram of each other624
94Remove recurring digits in a given number622
95Sort a linked list that is sorted alternating ascending and descending617
96Maximum Circular Subarray Sum617
97Sort a stack using a temporary stack615
98Find the Minimum Element in a Sorted and Rotated Array611
99Move last element of the Linked List at first place610
100Subarray and Subsequence607
101First Circular Tour to Visit all the Petrol Bunks605
102Largest Subarray with Equal Number of 0’s and 1’s602
103Compare two strings(linked lists)601
104Flattening a linked list600
105Maximum Element in an Array which is Increasing and then Decreasing599
106Palindrome Permutations of a String595
107Elements Appear more than N/K times in Array588
108Palindromes in a given range585
109Run length encoding584
110Majority Element584
111Print all permutations with repetition583
112Minimum insertions to form a shortest palindrome581
113Pangram Checking581
114Minimum Characters to be Added at Front to Make String Palindrome573
115Rearrange a given linked list in-place572
116Remove all duplicates in a sorted linked list571
117Merge a linked list into another at alternate positions571
118Rotate string to get lexicographically minimum string569
119Most repeating character in a string569
120Minimum number of Merge Operations to make an Array Palindrome568
121Repeated Subsequence of Length Two or More566
122Print all anagrams together in a sequence of words561
123Reorder an Array According to the Given Indexes557
124Pancake Sorting Problem548
125Two Sum Leetcode Solution546
126Merge Overlapping Intervals II546
127Clone a Linked List with next and random pointer544
1283Sum Leetcode Solution543
129Size of The Subarray With Maximum Sum534
130Transpose of a Matrix533
131Remove Extra Spaces from a String530
132Removing Spaces from a String using stringstream529
133Partition Problem527
134Remove duplicates from a string527
135Check if a given string is a rotation of a palindrome526
136Longest Palindrome can be Formed by Removing or Rearranging Characters525
137Smallest Palindrome after Replacement524
138Maximum Sum Increasing Subsequence524
139Check whether Strings are K Distance Apart or Not515
140Generate all Binary Strings from Given Pattern515
141Length of Longest valid Substring510
142Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized509
143Insert Node in the Sorted Linked List507
144Delete Last Occurrence506
145Check if Two given Strings are Isomorphic to each other502
146Maximum difference between two elements such as larger element comes after smaller495
147Program to Toggle all Characters in a String493
148Given string is interleaving of two other strings or not492
149Count Minimum Steps to Get the given Array487
150Merge sort better than quick sort for linked lists484
151Number of Smaller Elements on Right Side483
152Check length of a String is Equal to the Number Appended at its Last481
153Check if all Rows of a Matrix are Circular Rotations of Each Other480
154Find Pair with Given Difference480
155Find nth node of the Linked list from the end477
156Longest Common Prefix using Divide and Conquer477
157Sort 0s 1s and 2s in an Array468
158Print all interleavings of given two strings468
159Find a Fixed Point in a Given Array468
160Compare Two Version Numbers465
161Merge two sorted linked lists such that merged list is in reverse order462
162Reverse words in a given string462
163Reorder Array Using Given Indexes461
164Find the Subarray of given length with Least Average461
165Print Reverse of a string (Recursion)460
166Median of Two Sorted Arrays LeetCode Solution459
167Split linked list using alternate nodes459
168Print string of odd length in ‘X’ format445
169Print all Palindromic Partitions of a String441
170Find K Length Subarray of Maximum Average441
171Swap Kth Node from beginning with Kth Node from End441
172Find Element Using Binary Search in Sorted Array440
173Find Duplicates in an Array in Most Efficient Way433
174print all palindromic partitions427
175Shortest Superstring Problem424
176Flatten a multilevel linked list424
177Maximum Length of Chain Pairs423
178Check if String Follows Order of Characters by a Pattern or not420
179Sorting a K Sorted Array418
180Sort a String According to Another String413
181Longest Span with same Sum in two Binary Arrays II404
182Reverse a Linked List in groups402
183Find a Sorted Subsequence of size 3401
184Recursively print all the sentences that can be formed from list of word lists399
185Program to add two binary digits398
186Longest Common Prefix Using Binary Search II396
187Reverse a Singly Linked List (Iterative/Non-Recursive)394
188Find the two Numbers with Odd Occurrences in an Unsorted Array394
189Caesar Cipher390
190Kth Non-repeating Character389
191Rearrange a linked list in Zig-Zag386
192Check if String can Become Empty by Recursively Deleting given Substring385
193Longest Common Prefix Word by Word Matching382
194Pancake Sorting381
195Rotate Image by 90 degrees380
196Permutations of a Given String Using STL373
197Perfect Reversible String372
198Merging Two Sorted Arrays370
199Increasing Subsequence of Length three with Maximum Product368
2001`s and 2`s complement of binary number367
201Sort a linked list with 0s, 1s and 2s367
202Find the point where a monotonically increasing function becomes positive first time366
203Find First non-repeating character in a string366
204Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes366
205Four Elements that Sum to Given363
206List items containing all characters of a given word361
207Delete N nodes after M360
208Longest Common Prefix using Character by Character Matching357
209Count Number of Occurrences in a Sorted Array354
210Palindrome string (number)351
211Split a string349
212Minimum Characters to be Removed to Make a Binary String Alternate344
213Recursive Implementation of atoi()342
214Check if a Linked list of Strings form a Palindrome341
215Print All Distinct Elements of the Array339
216Sorting the array of strings339
217Maximum occurring character in a string337
218Even Substring Count336
219Convert a String that is Repetition of a Substring of Length K336
220Valid Parentheses LeetCode Solution335
221Reverse a singly linked list recursively334
222Find the first Repeating Number in a Given Array334
223Print Shortest Path to Print a String on Screen331
224Can we reverse a linked list in less than O(n) time ?331
225Convert string1 to string2 in one edit330
226Binary Tree to Doubly linked list329
227Nth Character in Concatenated Decimal String328
228Reverse a String using Stack326
229wildcard character matching326
230Sort Elements by Frequency II325
231Maximum Subarray Leetcode Solution324
232Lower Case To Upper Case324
233Merge Two Sorted Arrays319
234Count the number of words318
235Split Four Distinct Strings317
236Find the Lost Element From a Duplicated Array315
237Find middle of the Linked List313
238Longest Common Subsequence with Permutations309
239Matrix Chain Multiplication using Dynamic Programming309
240Count the Pairs at Same Distance as in English Alphabets309
241Next Greater Element in an Array303
242Palindrome Permutation299
243Find Nth Node293
244Roman to Integer Leetcode Solution293
245Searching a node in a Binary Search Tree291
246Find All Pairs With a Given Difference290
247Delete a Tree286
248Triplet from three linked lists with given sum286
249String(represents an integer) to value285
250Reverse a String284
251Word Search Leetcode Solution283
252Reverse Bits282
253Delete a node under given conditions282
254Print all Possible Ways to Break a String in Bracket Form281
255Change Gender of a given String279
256Binary Tree279
257Sort an array of strings277
258How to Efficiently Implement k Stacks in a Single Array?277
259Toeplitz Matrix276
260Count Pairs With Given Sum275
261First non Repeating Element274
262Meeting Rooms II LeetCode Solution273
263Number of sub-strings which recursively add up to 9273
264Repeated Substring Pattern272
265Remove middle points in a linked list of line segments271
266N queen problem271
267Longest Common Extension271
268Move all negative elements to one side of array270
269Remove spaces from a string268
270Longest Palindromic Substring LeetCode Solution266
271Min Stack264
272Shuffle a given Array264
273Dijkstra Algorithm261
274Number of Islands LeetCode Solution260
275Cuckoo sequence program259
276House Robber Leetcode Solution258
277Find, second, frequent, character258
278Max stack258
279Fibonacci numbers257
280Most Frequent Element in an Array256
281Minimize the maximum difference between the heights255
282Search Insert Position Leetcode Solution253
283Clone a linked list with next and random pointer (Hashing)253
284Expression Evaluation252
285Sort linked which is sorted on absolute values250
286KMP Algorithm250
287Subset Leetcode249
288Sudoku Solver249
289Valid Palindrome Leetcode Solution248
290Plus One Leetcode Solution247
291Word Search247
292Reverse words in a string246
293Number Of 1 bits246
294Evaluation of Postfix Expression246
295How to Delete a Linked List245
296Combination Sum Leetcode Solution245
297Min Stack Leetcode Solution244
298Backspace String Compare241
299Set Matrix Zeroes238
300Pair of Positive Negative Values in an Array237
301Sqrt(x) Leetcode Solution237
302Rabin Karp Algorithm237
303Merge Sorted Arrays Leetcode Solution236
304Reversing a Queue236
305Subarray with 0 sum234
306Tower Of Hanoi233
307Common elements in all rows of a given matrix233
308Combination Sum231
309Contains Duplicate II Leetcode Solution230
310Product of array except self230
311Delete middle element of a stack230
312Integer to Roman Leetcode Solution230
313Pascal Triangle Leetcode229
314String Compression228
315Intersection of Two Arrays II Leetcode Solution228
316Minimum swaps required to bring all elements less than or equal to k together227
317Reverse individual words227
318Segregate even and odd numbers226
319Construct Binary Tree from Given Inorder and Preorder Traversals225
320Find Top K (or Most Frequent) Numbers in a Stream225
321Count subarrays with equal number of 1’s and 0’s225
322Count of index pairs with equal elements in an array225
323Implementation of Deque using Doubly Linked List224
324Bellman Ford Algorithm224
325Sliding Window Technique224
326Add Binary Leetcode Solution224
327Count Odd Numbers in an Interval Range Leetcode Solution223
328Contains Duplicate223
329Minimum Value to Get Positive Step by Step Sum Leetcode Solution223
330Single Number Leetcode Solution223
331Find sum of non-repeating elements (distinct) elements in an array222
332Arithmetic Expression Evaluation222
333Postfix to Infix Conversion221
334Palindrome Linked List Leetcode Solution221
335Sort elements by frequency221
336Second Most Repeated Word in a Sequence221
337Pow(x, n) Leetcode Solution220
338Page Replacement Algorithms in Operating Systems219
339Maximum Number of Balloons Leetcode Solution219
340Next Permutation218
341Design a stack that supports getMin() in O(1) time and O(1) extra space218
342Group Words With Same Set of Characters218
343Kruskal Algorithm218
344Smallest Subarray with k Distinct Numbers216
345Sum of minimum and maximum elements of all subarrays of size k216
346Scramble String216
347K-th Smallest Element in a Sorted Matrix216
348Longest Common Prefix Leetcode Solution216
349Convex Hull Algorithm215
350Count subarrays having total distinct elements same as original array215
351Maximum Subarray215
352Third Maximum Number Leetcode Solution215
353Find Lucky Integer in an Array Leetcode Solution215
354Sorting array using Stacks214
355Minimum operation to make all elements equal in array214
356Longest Substring Without Repeating Characters LeetCode Solution214
357Permutations Leetcode Solution214
358Top K Frequent Words214
359Find the Town Judge Leetcode Solution213
360Find Numbers with Even Number of Digits Leetcode Solution212
361Special Number211
362Evaluate Division211
363Swap Nodes in Pairs Leetcode Solutions210
364Majority Element Leetcode Solution210
365Number of Good Pairs Leetcode Solution210
366Given two unsorted arrays find all pairs whose sum is x210
367Minimum Path Sum209
368Spiral Matrix LeetCode Solution209
369First element occurring k times in an array209
370Huffman Coding209
371Prefix to Infix Conversion208
372Check if two arrays are equal or not208
373Count Primes Leetcode Solutions207
374Reversing the First K elements of a Queue207
375Maximal Square207
376Reverse a Number Using Stack207
377Single Number207
378Merge Two Sorted Lists Leetcode Solutions207
379Missing Number Leetcode Solution206
380Pascal’s Triangle II Leetcode Solution206
381Group Anagrams206
382Best Time to Buy and Sell Stock  II Leetcode Solution206
383Running Sum of 1d Array Leetcode Solution205
384Search in Rotated Sorted Array Leetcode Solution205
385Minimum Absolute Difference Leetcode Solution205
386Find duplicates in a given array when elements are not limited to a range205
387Minimum Steps to reach target by a Knight205
388Palindrome Substring Queries204
389Maximum Distance Between two Occurrences of Same Element in Array204
390House Robber II Leetcode Solution204
391Sort Array by Increasing Frequency Leetcode Solution204
392Power of Two Leetcode Solution203
393Matrix Diagonal Sum Leetcode Solution203
394Maximum possible difference of two subsets of an array203
395Unique Paths202
396Range Sum Query 2D – Immutable Leetcode Solution202
397Find the first repeating element in an array of integers202
398Convert String To Int202
399Find Minimum In Rotated Sorted Array202
400Zigzag Conversion202
401Top K Frequent Elements202
402How to Implement Stack Using Priority Queue or Heap?202
403Find All Numbers Disappeared in an Array Leetcode Solution202
404Fizz Buzz Leetcode201
405Check if Array Contains Contiguous Integers With Duplicates Allowed201
406Find the Closest Palindrome number201
407Unique Paths Leetcode Solution201
408Sorting using trivial hash function201
409Expression Contains Redundant Bracket or Not201
410Smallest Element Repeated Exactly K Times201
411Subarray Sum Equals k201
412How Many Numbers Are Smaller Than the Current Number Leetcode Solution200
413Sort Integers by The Number of 1 Bit Leetcode Solution200
414Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution200
415Leetcode Permutations200
416Subset sum problem199
417Find Number of Employees Under every Employee199
418Decode String199
419Find Winner on a Tic Tac Toe Game Leetcode Solution199
420Letter Case Permutation199
421Max Consecutive Ones Leetcode Solution199
422Cumulative Frequency of Count of Each Element in an Unsorted Array199
423Difference between highest and least frequencies in an array198
424Monotonic Array LeetCode Solution198
425Coin Change 2 Leetcode Solution198
426Length of the largest subarray with contiguous elements198
427Happy Number Leetcode Solution198
428Nth Catalan Number197
429Subarray Sum Equals K LeetCode Solution197
430Print All Distinct Elements of a Given Integer Array197
431Sort a stack using recursion197
432Find top three repeated in array197
433Reverse Integer197
434Implement Stack and Queue using Deque197
435Best Time to Buy and Sell Stock III Leetcode Solution197
436Remove Duplicates from Sorted Array Leetcode Solution196
437Count Substrings with equal number of 0s, 1s and 2s196
438Fibonacci Number LeetCode Solution196
439Maximum Depth of Binary Tree Leetcode Solution196
440Print all subarrays with 0 sum196
441LRU Cache Implementation196
442Check If N and Its Double Exist Leetcode Solution196
443Subarrays with distinct elements195
444Sum of Subarray Ranges Leetcode Solution195
445Reverse Vowels of a String Leetcode Solution195
446Capacity To Ship Packages Within D Days Leetcode Solution195
447Prim’s Algorithm194
448Find The Duplicate Number194
449Generate a String With Characters That Have Odd Counts Leetcode Solution194
450Subtract the Product and Sum of Digits of an Integer Leetcode Solution194
451Find Median from data Stream194
452Reverse a Stack Using Recursion194
453Integer to English words193
454Kth largest element in an Array Leetcode Solutions193
455Merge Two Sorted Linked Lists193
456Bipartite Graph193
457Delete a Node from linked list without head pointer193
458Shuffle the Array Leetcode Solution193
459Reverse Words in a String III LeetCode Solution193
460Find elements which are present in first array and not in second192
461Find the Duplicate Element192
462Find the Difference Leetcode Solution192
463Find all pairs (a, b) in an array such that a % b = k192
464Find Common Characters Leetcode Solution192
465Count and Say192
466Trapping Rain Water Leetcode Solution192
467Count pairs from two linked lists whose sum is equal to a given value192
468Edit Distance192
469Target Sum192
470Sorting a Queue without Extra Space191
471Longest Common Subsequence191
472Remove Minimum Number of Elements Such That no Common Element Exist in both Array191
473Reverse a String191
474Excel Sheet Column Number Leetcode Solution190
475Priority Queue Using Singly Linked List190
476Floyd Warshall Algorithm190
477The K Weakest Rows in a Matrix Leetcode Solution190
478Fizz Buzz190
479Iterative Tower of Hanoi190
480Balanced Binary Tree Leetcode Solution190
481Reverse a linked list189
482Concatenation of Array LeetCode Solution189
483Text Justification LeetCode Solution189
484Longest Common Prefix using Trie189
485Degree of an array188
486Longest subarray not having more than K distinct elements188
487Prefix to Postfix Conversion188
488Kids With the Greatest Number of Candies Leetcode Solution188
489Flood Fill LeetCode188
490Merge Overlapping Intervals188
491Kth Largest Element in a Stream Leetcode Solution188
492Minimum Moves to Equal Array Elements Leetcode Solution188
493Design Parking System Leetcode Solution188
494Next Greater Element I Leetcode Solution188
495Find First and Last Position of Element in Sorted Array Leetcode Solution188
496Top View of Binary Tree187
497MiniMax Algorithm187
498Valid Parenthesis String187
499Find subarray with given sum (Handles Negative Numbers)187
500Slowest Key Leetcode Solution187
501Word Ladder LeetCode Solution187
502Number of Steps to Reduce a Number to Zero Leetcode Solution187
503Pair with given product186
504Multiply Strings Leetcode Solution186
505Find missing elements of a range186
506Shortest Palindrome186
507Zigzag Conversion LeetCode Solution186
508Find four elements that sum to a given value (Hashmap)186
509Find N Unique Integers Sum up to Zero Leetcode Solution186
510Priority Queue in C++186
511The Stock Span Problem186
512Count and Say Leetcode Solution185
513Postfix to Prefix Conversion185
514Max Area of Island185
515Convert array into Zig-Zag fashion185
516Jump Game Leetcode Solution185
517Move Zeroes LeetCode Solution184
518Find distinct elements common to all rows of a matrix184
519Find Index of Closing Bracket for a Given Opening Bracket in an Expression184
520Implement a stack using single queue184
521Mobile Numeric Keypad Problem184
522Find any one of the multiple repeating elements in read only array184
523Count number of triplets with product equal to given number184
524Substring With Concatenation Of All Words184
525Recursion184
526Length of Last Word Leetcode Solution184
527Check if a given array contains duplicate elements within k distance from each other184
528Rearrange a binary string as alternate x and y occurrences184
529Peak Index in a Mountain Array183
530Implement Stack using Queues183
531Largest Sum Contiguous Subarray183
532Shuffle String Leetcode Solution183
533Longest Common Prefix using Sorting183
534Next Greater Frequency Element183
535Intersection of Two Arrays183
536Iterative Inorder Traversal of a Binary Tree182
537Last Stone Weight182
538Contiguous Array Leetcode182
539Smallest Subarray With all Occurrences of a Most Frequent Element182
540Group Multiple Occurrence of Array Elements Ordered by first Occurrence181
541Relative Sort Array Leetcode Solution181
542Excel Sheet Column Title Leetcode Solution181
543Change the Array into Permutation of Numbers From 1 to N181
544Delete Node in a Linked List Leetcode Solution181
545Convert a normal BST to Balanced BST181
546Sum of Left Leaves Leetcode Solutions181
547Koko Eating Bananas Leetcode Solution181
548Valid Sudoku180
549Shuffle an Array180
550Linked List Cycle II LeetCode Solution180
551K-th Distinct Element in an Array180
552Assign Cookies Leetcode Solution180
553Minimum Bracket Reversals180
554Best Time to Buy and Sell Stock180
555Is Subsequence Leetcode Solution179
556Implementation of Deque using circular array179
557Integer to Roman179
558Number of Provinces Leetcode Solution179
559First negative integer in every window of size k179
560Minimum Operations to convert X to Y179
561Isomorphic Strings Leetcode Solution179
562Island Perimeter Leetcode Solution179
563Minimum Delete Operations to make all Elements of Array Same179
564N-th Tribonacci Number Leetcode Solution179
565Container with Most Water179
566Distribute Candies to People Leetcode Solution179
567Find Words That Can Be Formed by Characters Leetcode Solution179
568Largest Perimeter Triangle Leetcode Solution178
569Build Array From Permutation Leetcode Solution178
570Hamming Distance178
571Check for Balanced Parentheses in an Expression178
572Jewels and Stones Leetcode Solution178
573Arrange given numbers to form the biggest number178
574Minimum Knight Moves LeetCode Solution178
575Maximum path sum in a triangle177
576Count all subsequences having product less than K177
577Count the number of nodes at given level in a tree using BFS177
578The Knapsack Problem177
579Unique Binary Search Trees177
580Valid Anagrams177
581Combinations Leetcode Solution177
58201 Matrix LeetCode Solution177
583Summary Ranges Leetcode Solution177
584Convert Sorted Array to Binary Search Tree Leetcode Solution177
585Gold Mine Problem177
586Rotate List Leetcode Solution177
587LRU Cache LeetCode Solution176
588Trapping Rain Water LeetCode Solution176
589Remove Linked List Elements Leetcode Solution176
590Maximum sum rectangle in a 2D matrix176
591Shortest Path in a Grid with Obstacles Elimination LeetCode Solution175
592Decode Ways175
5933Sum Closest LeetCode Solution175
594Find the smallest positive integer value that cannot be represented as sum of any subset of a given array175
595Minimum number of subsets with distinct elements175
596Minimum number of distinct elements after removing m items174
597Find minimum difference between any two elements174
598Rotate Image LeetCode Solution174
599Minimum insertions to form a palindrome with permutations allowed174
600Find Sum of all unique sub-array sum for a given array174
601Maximum Distance in Array174
602Distance Between Bus Stops Leetcode Solution173
603How to check if two given sets are disjoint?173
604Bubble sort using two Stacks173
605Insert Interval Leetcode Solution173
606Maximum Number of Chocolates to be Distributed Equally Among k Students173
607Sort Characters By Frequency LeetCode Solution173
608Same Tree LeetCode Solution173
609Frog Jump Leetcode Solution172
610Painting Fence Algorithm172
611Reverse a stack without using extra space in O(n)172
612XOR Operation in an Array Leetcode Solution172
613Find if an Expression has Duplicate Parenthesis or Not172
614Minimum Cost to Hire K Workers172
615Stone Game LeetCode172
616Sieve of Eratosthenes172
617Defanging an IP Address Leetcode Solution172
618Longest Increasing Subsequence172
619Replace Elements with Greatest Element on Right Side Leetcode Solution171
620Remove All Occurrences of a Substring LeetCode Solution171
621Word Wrap Problem171
622Word Pattern171
623License Key Formatting Leetcode Solution171
624Permutation in String Leetcode Solution171
625Applications of Breadth First Search and Depth First Search171
626Find the Duplicate Number LeetCode Solution171
627Maximum Consecutive Numbers Present in an Array170
628Non-overlapping sum of two sets170
629Sort Array By Parity LeetCode Solution170
630Isomorphic Strings170
631Printing brackets in Matrix Chain Multiplication Problem170
632Best Time to Buy and Sell Stock LeetCode Solution170
633K Empty Slots LeetCode170
634House Robber170
635Smallest Good Base170
636Iterative Method to find Height of Binary Tree170
637Distance of nearest cell having 1 in a binary matrix170
638Segregate 0s and 1s in an Array169
639Longest Substring with At Least K Repeating Characters LeetCode Solution169
640Moving Average from Data Stream Leetcode Solution169
641Optimal Account Balancing LeetCode Solution169
642Minimum Depth of Binary Tree Leetcode Solution169
643Tracking current Maximum Element in a Stack169
644Binary Tree Zigzag Level Order Traversal LeetCode Solution168
645Queries for counts of array elements with values in given range168
646GCD Of Two Numbers168
647Kth Missing Positive Number Leetcode Solution168
648Wiggle Sort168
649Best Time to Buy and Sell Stock with Cooldown Leetcode Solution168
650Valid Palindrome II Leetcode Solution168
651Merge Two Balanced Binary Search Trees168
652Employee Free Time LeetCode Solution168
653Longest Substring with At Most K Distinct Characters LeetCode Solution168
654Coin Change Problem168
655Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions167
656Count Good Nodes in Binary Tree Leetcode Solution167
657Strobogrammatic Number LeetCode Solution167
658Path With Maximum Minimum Value LeetCode Solution167
659Reorganize String167
660Find Maximum Level sum in Binary Tree167
661How to Create Mergable Stack?167
662Valid Palindrome167
663Maximum difference between first and last indexes of an element in array167
664Check If It Is a Straight Line Leetcode Solution167
665Sum of All Odd Length Subarrays Leetcode Solution167
666Delete consecutive same words in a sequence166
667Remove Invalid Parentheses Leetcode Solution166
668Find Largest d in Array such that a + b + c = d166
669Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest166
670Check if a queue can be sorted into another queue using a stack166
671To Lower Case Leetcode Solution166
672Find the Distance Value Between Two Arrays Leetcode Solution166
673Maximum Number of Occurrences of a Substring Leetcode Solution166
674Flipping an Image LeetCode Solution166
675Maximum Number of Coins You Can Get Leetcode Solution165
676Partition Labels LeetCode Solution165
677Lucky Numbers in a Matrix Leetcode Solution165
678K Empty Slots165
679Inorder Successor of a node in Binary Tree165
680Letter Combinations of a Phone Number165
681Reducing Dishes LeetCode Solution165
682Print the Fibonacci numbers in reverse order165
683Increasing Decreasing String Leetcode Solution165
684Find pairs with given sum such that elements of pair are in different rows165
685Convert an array to reduced form165
686Partition Array Into Three Parts With Equal Sum Leetcode Solution165
687Sum of f(a[i], a[j]) over all pairs in an array of n integers165
688Check If Two String Arrays are Equivalent Leetcode Solution165
689Number of Dice Rolls With Target Sum LeetCode Solution164
690Delete Nth node from the end of the given linked list164
691BFS vs DFS for Binary Tree164
692Reverse Only Letters LeetCode Solution164
693Valid Perfect Square Leetcode Solution164
694Find the Smallest Divisor given a Threshold Leetcode Solution164
695Factorial Trailing Zeroes Leetcode Solution164
696Permutation Sequence LeetCode Solution164
697Recover Binary Search Tree163
698Unique Paths II Leetcode Solution163
699Convert a Number to Hexadecimal Leetcode Solution163
700Find whether an array is subset of another array163
701Populating Next Right Pointers in Each Node163
702Edit Distance LeetCode Solution163
703Binary Tree zigzag level order Traversal163
704Form minimum number from given sequence163
705Find Leaves of Binary Tree LeetCode Solution163
706Dynamic Programming Basics163
707Subset Sum Leetcode163
708Reversing a Queue using Recursion163
709String to Integer (atoi) LeetCode Solution163
710Longest Increasing Path in a Matrix LeetCode Solution163
711Maximum Product of Two Elements in an Array Leetcode Solution163
712Ugly Number Leetcode Solution163
713Power of Four Leetcode Solution163
714Reservoir Sampling162
715Sort Array by Increasing Frequency Leetcode Solution162
716Merge Two Binary Trees LeetCode Solution162
717Construct BST from given Preorder Traversal162
718Perform String Shifts Leetcode162
719Robot Room Cleaner Leetcode Solution162
720Decompress Run-Length Encoded List Leetcode Solution161
721Add and Search Word – Data structure design LeetCode161
722Keyboard Row Leetcode Solution161
723Binomial Coefficient161
724Find the node with minimum value in a Binary Search Tree161
725Find the largest multiple of 3161
726Bulb Switcher LeetCode Solution160
727Minimum Cost For Tickets Leetcode Solution160
728Tiling Problem160
729Majority Element II Leetcode Solution160
730Find Pair with Greatest Product in Array160
731Restore IP Addresses Leetcode Solution160
732Hamming Distance Leetcode Solution160
733Student Attendance Record I Leetcode Solution160
734Finding K closest element160
735Kth ancestor of a node in binary tree159
736Find Maximum Depth of Nested Parenthesis in a String159
737Non-decreasing Array LeetCode Solution159
738Minimum Distance Between BST Nodes Leetcode Solution159
739Word Pattern LeetCode Solution159
740Snakes and Ladders LeetCode Solution159
741Numbers with prime frequencies greater than or equal to k159
742Longest Span with same Sum in two Binary arrays159
743Check if Two Expressions With Brackets are Same159
744Find unique character in a string159
745Binary Tree Maximum Path Sum LeetCode Solution159
746Remove brackets from an algebraic string containing + and – operators159
747Generate all possible sorted arrays from alternate elements of two given sorted arrays159
748Race Car LeetCode Solution159
749Rank Transform of an Array Leetcode Solution159
750Linked List Cycle158
751Number of Islands II LeetCode Solution158
752Minimum Height Trees158
753Largest Rectangle in Histogram LeetCode Solution158
754Invert Binary Tree LeetCode Solution158
755Merge K Sorted Linked Lists158
756Sorted Linked List to Balanced BST158
757Maximum 69 Number Leetcode Solution158
758First Unique Character in a String LeetCode Solution158
759Stack Permutations (Check if an array is stack permutation of other)158
760Queue based approach for first non-repeating character in a stream158
761Diagonal Traversal of Binary Tree158
762String Compression LeetCode Solution158
763Maximum Product of Three Numbers LeetCode Solution158
764Minimum time required to rot all oranges158
765Maximum Depth of N-ary Tree Leetcode Solution158
766Morris Traversal158
767Transpose Graph157
768Best Meeting Point LeetCode Solution157
769Jump Game157
770Largest rectangular sub-matrix whose sum is 0157
771Find if Path Exists in Graph Leetcode Solution157
772Remove Nth Node From End of List Leetcode Solution157
773Largest subarray with equal number of 0s and 1s157
774Minimize Maximum Pair Sum in Array LeetCode Solution157
775Final Prices With a Special Discount in a Shop Leetcode Solution157
776Program for Bridge and Torch problem156
777Find All Duplicates in an Array LeetCode Solution156
778k-th missing element in increasing sequence which is not present in a given sequence156
779Total Numbers With no Repeated Digits in a Range156
780Special Array With X Elements Greater Than or Equal X Leetcode Solution156
781Partition to K Equal Sum Subsets Leetcode Solution156
782Symmetric Tree Leetcode Solution156
783Maximum Difference Between Increasing Elements LeetCode Solution156
784Check If Array Pairs Are Divisible by k LeetCode Solution156
785Evaluate Reverse Polish Notation LeetCode Solution156
786One Edit Distance LeetCode Solution156
787Maximum Length of a Concatenated String with Unique Characters Leetcode Solution156
788Elements to be added so that all elements of a range are present in array156
789Growable array based stack156
790Longest Subarray Having Count of 1s One More than Count of 0s155
791Check for Palindrome after every character replacement Query155
792Search a 2D Matrix II Leetcode Solution155
793Split a String in Balanced Strings Leetcode Solution155
794Number of NGEs to the Right155
795Interval Tree155
796Crawler Log Folder Leetcode Solution155
797Count items common to both the lists but with different prices155
798Search in a Binary Search Tree Leetcode Solution155
799Print a Binary Tree in Vertical Order155
800Find Median from Data Stream LeetCode Solution155
801Sort an array according to the order defined by another array155
802String comparison containing wildcards154
803Number Complement Leetcode Solution154
804Base 7 Leetcode Solution154
805Nested List Weight Sum II LeetCode Solution154
806Nearest Exit from Entrance in Maze LeetCode Solution154
807Circular Queue154
808Merge Sorted Array LeetCode Solution154
809Valid Number154
810Minimum Time Visiting All Points Leetcode Solution154
811Minimum swaps to make sequences increasing154
812Minimum Jumps to Reach Home LeetCode Solution154
813Count quadruples from four sorted arrays whose sum is equal to a given value x154
814Deletion in a Binary Tree154
815Course Schedule II – LeetCode154
816N-Queens LeetCode Solution154
817Spiral Matrix II Leetcode Solution153
818Convert BST to Min Heap153
819Reorder Data in Log Files LeetCode Solution153
820Sort Array By Parity II Leetcode Solution153
821Maximum Profit in Job Scheduling Leetcode Solution153
822Remove Duplicates from Sorted List II153
823Minimum number of jumps to reach end153
824Get Maximum in Generated Array Leetcode Solution153
825A Space Optimized DP solution for 0-1 Knapsack Problem153
826Last Stone Weight II LeetCode Solution153
827Subarray Product Less Than K LeetCode Solution152
828Maximum size subarray sum equals k152
829Iterative Preorder Traversal152
830Regular Expression Matching152
831Form Minimum Number From Given Sequence152
832Relative Ranks Leetcode Solution152
833Find all triplets with zero sum152
834Priority Queue using doubly linked list152
835Remove Duplicates from Sorted List LeetCode Solution152
836Find the subarray with least average152
837Find Maximum Sum Possible Equal Sum of Three Stacks152
838Minimum Swaps to Make Strings Equal Leetcode Solution152
839Identify and Mark Unmatched Parenthesis in an Expression151
840Path with maximum average value151
841Number of Days Between Two Dates LeetCode Solution151
842Sequences of given length where every element is more than or equal to twice of previous151
843LCS (Longest Common Subsequence) of three strings151
844Subset with sum divisible by m151
845Insert into a Binary Search Tree Leetcode Solution151
846Alien Dictionary LeetCode Solution151
847Permutation Coefficient151
848Partition List Leetcode Solution151
849Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution151
850Can Place Flowers LeetCode Solution151
851Maximum Nesting Depth of the Parentheses Leetcode Solution151
852Tree Traversal (Preorder, Inorder & Postorder)151
853Sort Colors151
854Sum of nearest smaller and greater number150
855Guess Number Higher or Lower LeetCode Solution150
856Find the Only Repetitive Element Between 1 to N-1150
857Level order Traversal in Spiral Form150
858Count Distinct Elements in Every Window of Size K150
859Design a Stack With Increment Operation Leetcode Solution150
860Find All Possible Recipes from Given Supplies LeetCode Solution150
861Check if a given array can represent Preorder Traversal of Binary Search Tree150
862Friends Pairing Problem150
863Subsequence of Size K With the Largest Even Sum LeetCode Solution150
864Brick Wall LeetCode Solution150
865Top K Frequent Words LeetCode Solution150
866Count Negative Numbers in a Sorted Matrix LeetCode Solution150
867Minimum Number of Taps to Open to Water a Garden LeetCode Solution150
868Check whether a given Binary Tree is Complete or not150
869Given an Array of Pairs Find all Symmetric Pairs in it150
870Minimum Sum Path in a Triangle150
871Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution150
872Binary Search Tree Search and Insertion150
873Valid Parentheses Leetcode Solution150
874Find Common Characters Leetcode Solution149
875Missing Element in Sorted Array LeetCode Solution149
876Clone Graph LeetCode Solution149
877Range LCM Queries149
878Brightest Position on Street LeetCode Solution149
879GCDs of given index ranges in an array149
880Range sum queries without updates149
881Union and Intersection of two Linked Lists149
882Find distance between two nodes of a Binary Tree149
883Distinct adjacent elements in an array149
884Matrix Chain Multiplication149
885Destination City Leetcode Solution149
886Check if stack elements are pairwise consecutive149
887Repeated Substring Pattern LeetCode Solution149
888Sorted Array to Balanced BST149
889Balanced Expression with Replacement149
890K’th Largest Element in BST when modification to BST is not allowed148
891Time Based Key-Value Store LeetCode Solution148
892Shortest Word Distance Leetcode Solution148
893Construct Complete Binary Tree from its Linked List Representation148
894Check if an Array is Stack Sortable148
895Minimum sum of multiplications of n numbers148
896Rearrange an Array Such that arr[i] is equal to i148
897Three way partitioning of an array around a given range148
898An Interesting Method to generate Binary Numbers from 1 to n148
899Diagonal Traverse LeetCode Solution148
900Design Browser History LeetCode Solution148
901BFS for Disconnected Graph148
902Count ways to reach the nth stair using step 1, 2 or 3148
903Water Bottles Leetcode Solution148
904Least Number of Unique Integers after K Removals Leetcode Solution147
905Guess Number Higher or Lower II147
906Delete And Earn147
907Queries for GCD of all numbers of an array except elements in a given range147
908Lemonade Change Leetcode Solution147
909Diagonal Traversal LeetCode Solution147
910Daily Temperatures Leetcode Solution147
911Rearrange Spaces Between Words Leetcode Solution147
912Insert Delete GetRandom147
913Averages of Levels in Binary Tree147
914Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i147
915Convert Sorted List to Binary Search Tree147
916Spiral Matrix III LeetCode Solution147
917Count Subarrays with Same Even and Odd Elements146
918Special Positions in a Binary Matrix Leetcode Solution146
919Queue using Stacks146
920Robot Bounded In Circle LeetCode Solution146
921Maximum Score After Splitting a String Leetcode Solution146
922Set Matrix Zeroes Leetcode Solution146
923Find all permuted rows of a given row in a matrix146
924Vertical sum in a given binary tree146
925Median of Two Sorted Arrays145
926Merge Two Sorted Lists Leetcode145
927Split Array Into Consecutive Subsequences145
928Check if the given array can represent Level Order Traversal of Binary Search Tree145
929Alien Dictionary145
930Construct the Rectangle Leetcode Solution145
931Dividing Array into Pairs With Sum Divisible by K145
932Check if any two intervals overlap among a given set of intervals145
933Maximum Subarray Sum Excluding Certain Elements145
934Palindrome Partitioning Leetcode Solution145
935Number of Distinct Islands Leetcode Solution145
936A program to check if a binary tree is BST or not145
937Binary Tree Longest Consecutive Sequence LeetCode Solution145
938Largest area rectangular sub-matrix with equal number of 1’s and 0’s145
939Iterative Postorder Traversal Using Two Stacks145
9404Sum144
941Longest Palindromic Subsequence144
942Construct BST from its given Level Order Traversal144
943Three Consecutive Odds Leetcode Solution144
944Print Fibonacci sequence using 2 variables144
9453 Sum144
946All Unique Triplets that Sum up to a Given Value144
947Lexicographical Numbers Leetcode Solution144
948Maximum Product Subarray143
949Strongly Connected Component143
950Stone Game II Leetcode143
951Number of Equivalent Domino Pairs Leetcode Solution143
952Maximum Frequency Stack Leetcode Solution143
953Create Maximum Number143
954Analyze User Website Visit Pattern LeetCode Solution143
955Difference Array | Range update query in O(1)143
956Remove Duplicates from Sorted List II LeetCode Solution143
957Minimum Height Trees LeetCode Solution143
958Count Submatrices With All Ones LeetCode Solution143
959Sliding Window Maximum143
960Maximize Sum of Array after K Negations Leetcode Solution143
961Length of Longest Fibonacci Subsequence142
962Trim a Binary Search Tree142
963Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space142
964Count subarrays where second highest lie before highest142
965Infix to Postfix142
966Collect maximum points in a grid using two traversals142
967Binary array after M range toggle operations142
968My Calendar I LeetCode Solution142
969Unique Paths II142
970Can Make Arithmetic Progression From Sequence Leetcode Solution142
971The Painter’s Partition Problem141
972Find postorder traversal of BST from preorder traversal141
973Merging Intervals141
974Minesweeper LeetCode Solution141
975Find the Difference Leetcode Solution141
976Symmetric Tree141
977Count pair with Given Sum141
978Intersection of Two Linked Lists LeetCode Solution141
979Kth Smallest Element in a BST Leetcode Solution141
980Find Maximum of Minimum for Every Window Size in a Given Array141
981Count Primes in Ranges141
982Product of Array Except Self LeetCode Solution140
983Reverse Nodes in K-Group140
984Boundary Traversal of binary tree140
985K Closest Points to Origin Leetcode Solution140
986Longest Nice Substring LeetCode Solution140
987Valid Boomerang Leetcode Solution140
988Climbing stairs140
989Height of a generic tree from parent array140
990Word Break140
991Sign of the Product of an Array LeetCode Solution140
992Palindrome Partitioning140
993Pattern Occurrences using Stack140
994Minimum Index Sum of Two Lists140
995Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution140
996Number Of Longest Increasing Subsequence139
997Binary Search Tree Delete Operation139
998Graph Valid Tree LeetCode Solution139
999Maximum Sum of 3 Non-Overlapping Subarrays139
1000Find the First Circular Tour that visits all the Petrol Pumps139
1001Largest Number Leetcode Solution139
1002Newman-Conway Sequence139
1003Friends Of Appropriate Ages LeetCode Solution139
1004Largest divisible pairs subset139
1005Breadth First Search (BFS) for a Graph139
1006Maximum length subsequence with difference between adjacent elements as either 0 or 1139
1007Level Order Traversal of Binary Tree139
1008Largest Substring Between Two Equal Characters Leetcode Solution139
1009Asteroid Collision LeetCode Solution139
1010Segment Tree139
1011Merge Sort138
1012Construction of Longest Increasing Subsequence (N log N)138
1013Double the first element and move zero to end138
1014Maximum Length of Repeated Subarray138
1015Find Duplicate Subtrees138
1016Rearrange array such that even positioned are greater than odd138
1017Shortest Completing Word Leetcode Solution138
1018Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’138
1019Insertion in a Binary Tree138
1020Maximum Number of Ways to Partition an Array LeetCode Solution138
1021K maximum sums of overlapping contiguous sub-arrays138
1022Maximum subsequence sum such that no three are consecutive138
1023Find number of pairs in an array such that their XOR is 0138
1024Construct Binary Tree from given Parent Array representation138
1025Longest subsequence such that difference between adjacents is one138
1026Scramble String LeetCode Solution138
1027The Maze III LeetCode Solution138
1028Boolean Parenthesization Problem138
1029Next Greater Element III LeetCode Solution138
1030Compute nCr % p138
1031Partition Equal Subset Sum137
1032Decrypt String from Alphabet to Integer Mapping Leetcode Solution137
1033Ugly Numbers137
1034Iterative Depth First Traversal of Graph137
1035Kill Process LeetCode Solution137
1036Maximum Product of Indexes of Next Greater on Left and Right137
1037String Matching in an Array Leetcode Solution137
1038Depth First Search (DFS) for a Graph137
1039Make The String Great Leetcode Solution137
1040Design Hit Counter LeetCode Solution137
1041Build an Array With Stack Operations Leetcode Solution137
1042Maximum weight transformation of a given string137
1043Binary Search Tree137
1044Number of palindromic paths in a matrix137
1045Available Captures for Rook Leetcode Solution136
1046Advantages of BST over Hash Table136
1047Count minimum steps to get the given desired array136
1048First missing positive136
1049Serialize and Deserialize Binary Tree136
1050Morris Inorder Traversal136
1051Level order traversal using two Queues136
1052Find a Peak Element II LeetCode Solution135
1053Custom Sort String Leetcode Solution135
1054Add two numbers135
1055Invalid Transactions LeetCode Solution135
1056Maximum difference between frequency of two elements such that element having greater frequency is also greater135
1057Balanced Binary Tree135
1058Kth Smallest Element in a Sorted Matrix LeetCode Solution135
1059Bitwise AND of Numbers Range LeetCode Solution135
1060Lowest Common Ancestor135
1061Generate Parentheses Leetcode Solution134
1062Combination Sum IV LeetCode Solution134
1063Employee Importance LeetCode Solution134
1064Ugly Number II LeetCode Solution134
1065Remove Duplicates from Sorted Array II Leetcode Solution134
1066Count pairs from two sorted arrays whose sum is equal to a given value x134
1067Path Sum II LeetCode Solution134
1068Regular Expression Matching Regular Expression Matching LeetCode Solution134
1069Find Peak Element134
1070Super Ugly Number134
1071Validate Binary Search Tree134
1072Minimum Size Subarray Sum134
1073Recover Binary Search Tree Leetcode Solution133
1074Binary Tree Right Side View LeetCode Solution133
1075Root to Leaf path with target sum Leetcode Solutions133
1076Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution133
1077Find whether a subarray is in form of a mountain or not133
1078Implement Trie (Prefix Tree) Leetcode Solution133
1079Rearrange array such that even index elements are smaller and odd index elements are greater133
1080Increasing Triplet Subsequence LeetCode Solution133
1081Defanging an IP Address LeetCode Solution133
1082Move all negative elements to end in order with extra space allowed133
1083Subarrays with K Different Integers Leetcode Solution132
1084Consecutive Characters LeetCode Solution132
1085Search in Sorted Rotated Array132
1086Populating Next Right Pointers in Each Node Leetcode Solution132
1087Largest BST Subtree LeetCode Solution132
1088Day of the Year Leetcode Solution132
1089Number of Closed Islands Leetcode Solution132
1090Find Smallest Range Containing Elements from k Lists131
1091Smallest Common Region Leetcode Solution131
1092Number of Students Doing Homework at a Given Time Leetcode Solution131
1093Longest Bitonic Subsequence131
1094Remove Palindromic Subsequences Leetcode Solution131
1095Count Largest Group Leetcode Solution131
1096Serialize and Deserialize Binary Tree LeetCode Solution131
1097Types of Binary Tree131
1098Kth Smallest Product of Two Sorted Arrays LeetCode Solution130
1099Maximize Distance to Closest Person LeetCode Solution130
1100Print all triplets in sorted array that form AP130
1101Level of Each node in a Tree from source node130
1102Minimum Absolute Difference in BST Leetcode Solution130
1103Next Permutation Leetcode Solution130
1104Clone a Binary Tree with Random Pointers130
1105Find the minimum distance between two numbers130
1106Remove duplicates from sorted array130
1107Distinct Subsequences130
1108Number of siblings of a given Node in n-ary Tree130
1109Binary Tree Data Structure130
1110Find maximum difference between nearest left and right smaller elements130
1111Convert BST into a Min-Heap without using array130
1112Find Three Element From Different Three Arrays Such That a + b + c = sum130
1113Bottom View of a Binary Tree129
1114Write Code to Determine if Two Trees are Identical129
1115Cutting a Rod129
1116Path Sum129
1117Divisible Pairs Counting129
1118Construct K Palindrome Strings LeetCode Solution129
1119Palindrome Permutation LeetCode Solution129
1120Sum of Even Numbers After Queries129
1121Third Maximum Number Leetcode Solution129
1122Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution129
1123Print Next Greater Number of Q queries129
1124Thousand Separator Leetcode Solution129
1125Maximum Product Subarray128
1126Print Right View of a Binary Tree128
1127Mean of Array After Removing Some Elements Leetcode Solution128
1128Delete Nodes and Return Forest Leetcode Solution128
1129Valid Tic-Tac-Toe State LeetCode Solution128
1130Minimum sum of squares of character counts in a given string after removing k characters128
1131Minimum Score Triangulation of Polygon Leetcode Solution128
1132Queries for Number of Distinct Elements in a Subarray128
1133Iterative method to find ancestors of a given binary tree128
1134Longest Increasing Consecutive Subsequence128
1135Diameter of N-Ary Tree LeetCode Solution128
1136Products of ranges in an array128
1137Reformat The String Leetcode Solution128
1138Constant time range add operation on an array128
1139Longest Subarray of 1’s After Deleting One Element LeetCode Solution127
1140Maximum Product of Splitted Binary Tree LeetCode Solution127
1141Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution127
1142Prime Palindrome LeetCode Solution127
1143Swap Nodes In Pairs126
1144Cells with Odd Values in a Matrix LeetCode Solution126
1145Moser-de Bruijn Sequence126
1146Find maximum length Snake sequence126
1147Search an Element in Sorted Rotated Array126
1148Subset Sum Problem in O(sum) space126
1149Palindromic Substrings Leetcode Solution126
1150Search Insert Position126
1151Maximum Binary Tree125
1152Bus Routes Leetcode Solution125
1153Kth Smallest Number in Multiplication Table Leetcode Solution125
1154Print modified array after executing the commands of addition and subtraction125
1155Merge two BSTs with limited extra space125
1156Topological Sorting125
1157Priority Queue125
1158Transform a BST to Greater sum Tree125
1159Red-Black Tree Introduction125
1160Closest Binary Search Tree Value Leetcode Solution124
1161Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution124
1162Maximize sum of consecutive differences in a circular array124
1163Check Array Formation Through Concatenation Leetcode Solution124
1164Possible Bipartition LeetCode Solution123
1165Given a binary tree, how do you remove all the half nodes?123
1166Minimum Sideway Jumps LeetCode Solution123
1167Golomb sequence123
1168K’th Largest element in BST using constant extra space123
1169Count even length binary sequences with same sum of first and second half bits123
1170Web Crawler LeetCode Solution123
1171Search Suggestions System LeetCode Solution123
1172Find Largest Value in Each Tree Row LeetCode Solution123
1173Minimum Cost to Move Chips to The Same Position LeetCode Solution123
1174Decision Tree123
1175Rotate Array123
1176Factorial Trailing Zeroes LeetCode Solution122
1177Find a sorted subsequence of size 3 in linear time122
1178Minimum Moves to Equal Array Elements LeetCode Solution122
1179Longest Repeated Subsequence122
1180Find the smallest binary digit multiple of given number122
1181Maximum number of segments of lengths a, b and c122
1182Contiguous Array LeetCode Solution122
1183Binary Tree to Binary Search Tree Conversion122
1184Compare Strings by Frequency of the Smallest Character Leetcode Solution122
1185Valid Triangle Number121
1186Matchsticks to Square Leetcode Solution121
1187Lowest Common Ancestor in Binary Search Tree121
1188Decrease Elements To Make Array Zigzag LeetCode Solution121
1189Reverse a Path in BST using Queue121
1190Closest Leaf in a Binary Tree LeetCode Solution121
1191Maximum Depth Of Binary Tree121
1192Swapping Nodes in a Linked List Leetcode Solution121
1193Graph and its representation121
1194Sum of Left Leaves LeetCode Solution121
1195First Bad Version121
1196Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution120
1197Maximum sum bitonic subarray120
1198Reformat Date LeetCode Solution120
1199Count Pairs Whose Products Exist in Array120
1200Maximum sum of pairs with specific difference120
1201Queue Reconstruction by Height120
1202Range Queries for Longest Correct Bracket Subsequence120
1203Convert Sorted Array to Binary Search Tree LeetCode Solutions120
1204Number of Orders in the Backlog Leetcode Solution120
1205Concatenation of Array LeetCode Solution119
1206Champagne Tower LeetCode Solution119
1207Path Crossing Leetcode Solution119
1208How to print maximum number of A’s using given four keys119
1209Lowest Common Ancestor of a Binary Tree Leetcode Solution119
1210Moving Stones Until Consecutive Leetcode Solution119
1211Minimum Swaps To Make Sequences Increasing LeetCode Solution118
1212Queries on Probability of Even or Odd Number in given Ranges118
1213Kth Smallest Element in a BST118
1214Write a function to get the intersection point of two Linked Lists118
1215BST to a Tree with Sum of all Smaller Keys118
1216Perfect Squares LeetCode Solution118
1217Divide Two Integers Leetcode Solution118
1218Integer Break LeetCode Solution117
1219Maximize Elements Using Another Array117
1220Maximum Value at a Given Index in a Bounded Array LeetCode Solution117
1221Valid Perfect Square LeetCode Solution117
1222Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution117
1223Guess The Word117
1224Array Queries for multiply replacements and product117
1225LRU Cache Leetcode Solution117
1226Replace two consecutive equal values with one greater117
1227Check if all levels of two Binary Tree are anagrams or not117
1228Flatten 2D Vector LeetCode Solution116
1229Power of Two116
1230Mean of range in array116
1231Count Subsets Having Distinct Even Numbers116
1232Sliding Window Median Leetcode Solution116
1233Maximum sum of a path in a Right Number Triangle116
1234New 21 Game116
1235Parallel Courses II LeetCode Solution115
1236Design Skiplist LeetCode Solution115
1237Print modified array after multiple array range increment operations115
1238Range Sum Query using Sparse Table115
1239Check Completeness of a Binary Tree LeetCode Solution115
1240Missing Number115
1241Arithmetic Slices II – Subsequence LeetCode Solution115
1242The kth Factor of n Leetcode Solution115
1243Maximum Array from Two given Arrays Keeping Order Same115
1244Graph Cloning114
1245Check for Identical BSTs without building the trees114
1246Contiguous Array114
1247Find Minimum in Rotated Sorted Array II LeetCode Solution114
1248Find k-th smallest element in BST (Order Statistics in BST)114
1249Check if each internal node of a BST has exactly one child114
1250Longest Common Prefix Using Word by Word Matching114
1251Bold Words in String LeetCode Solution114
1252Find minimum number of merge operations to make an array palindrome114
1253Merge k Sorted Lists Leetcode Solution113
1254Print Ancestors of a Given Binary Tree Node Without Recursion113
1255Largest Plus Sign Leetcode Solution113
1256Maximum Product Subarray113
1257Check if two nodes are on the same path in a Tree112
1258Image Overlap LeetCode Solution112
1259Print n terms of Newman-Conway Sequence112
1260Symmetric Tree LeetCode Solution Leetcode Solution112
1261Verify Preorder Serialization of a Binary Tree111
1262Minimum Remove to Make Valid Parentheses LeetCode Solution111
1263Count and Toggle Queries on a Binary Array111
1264Excel Sheet Column Title LeetCode Solution111
1265Smallest Range II Leetcode Solution110
1266Minimum Time to Collect All Apples in a Tree LeetCode Solution110
1267Number of elements less than or equal to a given number in a given subarray110
1268Palindrome Partitioning109
1269Next greater element109
1270Check If a String Can Break Another String Leetcode Solution109
1271Orderly Queue LeetCode Solution108
1272Min Cost Climbing Stairs LeetCode Solution108
1273Koko Eating Bananas LeetCode Solution107
1274Different Ways to Add Parentheses Leetcode Solution107
1275Longest Substring Without Repeating Characters Leetcode Solution106
1276Check in binary array the number represented by a subarray is odd or even106
1277Peeking Iterator LeetCode Solution106
1278Largest Submatrix With Rearrangements LeetCode Solution106
1279Check if X can give change to every person in the Queue105
1280Newman–Shanks–Williams prime105
1281Merge Sorted Array105
1282Range Minimum Query (Square Root Decomposition and Sparse Table)104
1283Queries for Decimal Values of Subarrays of a Binary Array104
1284Maximum product of an increasing subsequence102
1285Maximum Sum Increasing Subsequence102
1286Find maximum average subarray of k length102
1287Array Nesting Leetcode Solution102
1288Number of indexes with equal elements in given range102
1289Encoded String With Shortest Length LeetCode Solution102
1290Arranging Coins Leetcode Solution102
1291Check given array of size n can represent BST of n levels or not101
1292Convert a BST to a Binary Tree such that sum of all greater keys is added to every key100
1293Minimum Total Space Wasted With K Resizing Operations LeetCode Solution99
1294Minimum Number of People to Teach LeetCode Solution99
1295Find the Winner of the Circular Game LeetCode Solution99
1296Convert to Base -2 LeetCode Solution99
1297Random Pick Index LeetCode Solution98
1298Binary Tree to Binary Search Tree Conversion using STL set98
1299Continuous Subarray Sum LeetCode Solution98
1300Jump Game IV LeetCode Solution98
1301Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution98
1302Vertical Order Traversal of Binary Tree LeetCode Solution97
1303Reach a Number LeetCode Solution97
1304Add Two Numbers II Leetcode Solution97
1305Queries on XOR of greatest odd divisor of the range96
1306Insert Delete GetRandom O(1) Leetcode Solution95
1307Palindrome Number LeetCode Solution95
1308Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution95
1309Design Underground System Leetcode Solution91
1310Shifting Letters LeetCode Solution90
1311Print Maximum Length Chain of Pairs89
1312Design A Leaderboard Leetcode Solution88
1313Detect Capital Leetcode Solution88
1314Substring with Concatenation of All Words Leetcode Solution85
1315Minimum Swaps to Group All 1’s Together Leetcode Solution84
1316Top K Frequent Elements LeetCode Solution83
1317Count Sub Islands LeetCode Solution83
1318Minimum Path Sum Leetcode Solution82
1319Binary Tree Inorder Traversal LeetCode Solution81
1320Odd Even Linked List Leetcode Solution79
1321Maximum Population Year LeetCode Solution78
1322Longest Common Subsequence LeetCode Solution78
1323Decode String Leetcode Solution78
1324Best Meeting Point LeetCode Solution77
1325Find the Town Judge LeetCode Solution77
1326Shortest Unsorted Continuous Subarray LeetCode Solution76
1327Find the Town Judge LeetCode Solution76
1328Sum Root to Leaf Numbers LeetCode Solution75
1329Rectangle Overlap LeetCode Solution72
1330Maximum Population Year LeetCode Solution71
1331Design Add and Search Words Data Structure LeetCode Solution71
1332Flatten Binary Tree to Linked List LeetCode Solution69
1333Score of Parenthesis LeetCode Solution69
1334Stone Game IV LeetCode Solution68
1335Insert into a Sorted Circular Linked List LeetCode Solution68
1336Range Sum Query 2D – Immutable LeetCode Solution66
1337Reveal Cards In Increasing Order Leetcode Solution65
1338Valid Triangle Number LeetCode Solution64
1339Is Graph Bipartite? LeetCode Solution64
1340Divide Chocolate LeetCode Solution57
1341Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution53
1342Reverse Integer Leetcode Solution47
1343Range Sum of BST LeetCode Solution46
1344Find K Closest Elements LeetCode Solution43
1345Sort Colors LeetCode Solution43
1346Rotate String LeetCode Solution40
1347Maximum Side Length of a Square with Sum Less than or Equal to Threshold LeetCode Solution40
1348Excel Sheet Column Number LeetCode Solution39
1349Maximum Size Subarray Sum Equals k Leetcode Solution20
1350H-Index Leetcode Solution20
1351High Five LeetCode Solution19
1352Camelcase Matching Leetcode Solution18
1353Monotonic Array Leetcode Solution16
1354Valid Anagram Leetcode Solution14
1355Group Shifted Strings Leetcode Solution14
1356Insert Delete GetRandom O(1) – Duplicates allowed LeetCode Solution12
1357Peak Index in a Mountain Array LeetCode Solution12
1358Unique Binary Search Trees LeetCode Solution11
1359Pairs of Songs With Total Durations Divisible by 60 LeetCode Solution11
1360Next Greater Element I Leetcode Solution11
1361Next Permutation LeetCode Solution11
1362Closest Binary Search Tree Value II LeetCode Solution10
1363Container With Most Water LeetCode Solution10
1364Flatten Binary Tree to Linked List LeetCode Solution10
1365Minimum Number of Arrows to Burst Balloons LeetCode Solution10
1366Valid Triangle Number LeetCode Solution10
1367Paint House LeetCode Solution9
1368Isomorphic Strings LeetCode Solution9
1369Sentence Screen Fitting LeetCode Solution8
1370Swim in Rising Water LeetCode Solution7
1371Binary Search LeetCode Solution6
1372Group Anagrams LeetCode Solution5
1373Sliding Window Maximum LeetCode Solution4
1374Find Peak Element LeetCode Solution
Translate »