Single Element in a Sorted Array LeetCode Solution


Frequently asked in Adobe Amazon Apple Bloomberg eBay Google Microsoft Nvidia Oracle Twitter YahooViews 26

Problem Statement:

Single Element in a Sorted Array LeetCode Solution says that –  You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.

Return the single element that appears only once.

Your solution must run in O(log n) time and O(1) space.

Example 1:

Input:

 nums = [1,1,2,3,3,4,4,8,8]

Output:

 2

Example 2:

Input:

 nums = [3,3,7,7,10,11,11]

Output:

 10

Constraints:

  • 1 <= nums.length <= 105
  • 0 <= nums[i] <= 105

ALGORITHM –

IDEA –

  • In order to find a single Element in a Sorted Array. First, we will use the concept of binary search and xor in this question.
  • Basically, we will focus on the single element in this question. So our position starts with an even index i.e zero and according to questions, every element will occur double time except a single element. We will start with the even index then odd then even and repeat…..
  • if our element is present at the event index that means this is the first one of the double element so if our element present at the even index then we will check for the next element by using XOR and if the next element is the same as previous that’s mean the sequence is correct from starting or we can say that there is no single element in an array till now.
  • The same is in the case of the odd index. odd index means the element is the second one of double if the element is at the odd index then will check for the previous one and if both match then we can say that there is no single element present till now.
  • We will check all the conditions using Binary search if the middle element is equal to middle^1 then low = mid+1 i.e no single element is present in the array from starting to till now.
  • Else high = mid. i.e single element is present in the array in the first half.

      XOR VALUES –

EVEN –                                                           ODD –

0^1 = 1                                                      1^1 = 0

2^1 = 3                                                     3^1 = 2

4^1 = 5                                                     5^1 = 4

6^1 = 7                                                      7^1 = 6

  • At last, we will return nums[low].
  • Hence, we will find the Single Element in a Sorted Rotated Array.

Image –

Single Element in a Sorted Array LeetCode SolutionPin Single Element in a Sorted Array LeetCode SolutionPin

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

Complexity Analysis for Single Element in a Sorted Array LeetCode Solution

Time Complexity : O(LOGN), As we have used Binary Search in this question.

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

Similar Question – https://www.tutorialcup.com/leetcode-solutions/single-number-leetcode-solution.htm

 

Top Interview Questions

S.No Interview Question Number of times has been asked
1Delete a node in doubly linked list2887
2Java program to find the number of Nodes in a Binary Tree2541
3Reverse a string without affecting special characters2524
4Palindrome using Recursion2488
5Delete a node of a linked list at given position2022
6Quick Sort1768
7Insert nodes in a linked list in a sorted way (Ascending Order)1709
8Find elements pair from array whose sum equal to number1686
9Sort Elements by Frequency of Occurrences1672
10Write a program to print all permutations of a given string1655
11Find Minimum Distance Between Two Numbers in an Array1517
12Create a Doubly Linked List1484
13Reverse an Array1461
14Smallest window in a string containing all characters of another string1436
15Recursively remove all adjacent duplicates1405
16Find a Triplet That Sum to a Given Value1391
17First Repeating Element1384
18Sum of numbers in String1361
19Arrange Even and Odd number such that Odd comes after Even1357
20Smallest Positive Number Missing in an Unsorted Array1326
21Check if the Elements of an Array are Consecutive1290
22Detect a loop in the Linked List1272
23Largest Sum Contiguous Subarray1260
24Quick Sort on SIngly Linked List1256
25Subarray with Given Sum1247
26Recursive function to do substring search1245
27Print all Possible Combinations of R Elements in a given Array of size N1245
28Find the Maximum Repeating Number in Array1203
29Find the First and Second Smallest Elements1155
30Binary Tree Level order traversal in Java1155
31Check if two linked lists are identical1141
32Maximum Subarray Sum using Divide and Conquer1141
33Remove characters from first string which are in second1114
34Find Leaders in an Array1092
35Swap nodes in the linked list1083
36Find the second most frequent character1034
37Find the Number Occurring Odd Number of Times in an Array1033
38Arrange given Numbers to Form the Biggest Number II1027
39Given a string find its first non-repeating character1014
40Find Triplet in Array With a Given Sum1002
41Given a sorted array and a number x, find the pair in array whose sum is closest to x993
42Total number of occurrences of a given item in the linked list991
43A Program to check if strings are rotations of each other or not987
44Print all possible words from phone digits972
45Find the Missing Number962
46Rearrange Positive and Negative Numbers Alternatively in Array950
47Longest Palindromic Substring944
48Segregate even and odd nodes in a linked list933
49Print Longest common subsequence924
50Transform one string to another using minimum number of given operations911
51Union and Intersection of Two Linked Lists905
52Check rearranged string can form a palindrome895
53Rearrange given Array in Maximum Minimum Form876
54Iterative Implementation of Quick Sort868
55Insertion Sort857
56Count Possible Triangles855
57Multiplication of Two Matrices840
58Count of Triplets With Sum Less than Given Value829
59Stock Buy Sell to Maximize Profit827
60Rotate a Linked List825
61Check if the linked list is palindrome824
62Concatenation of two strings804
63Tug of War797
64Print all duplicates in the input string796
65Count Number of Substrings with K Distinct Character’s794
66Find Nearest Greater and Smaller Element782
67Reverse String Without Temporary Variable776
68The Celebrity Problem771
69Remove ‘b’ and ‘ac’ from a given string769
70Find Pythagorean Triplets from Array768
71Find all Common Elements in Given Three Sorted Arrays763
72Remove all duplicates in an unsorted linked list740
73Find the Row with Maximum Number of 1’s737
74Find the subarray whose sum is equal to a given number X736
75Remove Minimum Characters so that Two Strings Become Anagrams735
76Find the Peak Element from an Array733
77Addition of Two Matrices729
78Find Smallest Missing Number in a Sorted Array725
79Generate all Binary Strings Without Consecutive 1’s723
80A Product Array Puzzle720
81Maximum Sum of Non Consecutive Elements710
82Implement Two Stacks in an Array705
83Lexicographic rank of string697
84Check if Two given Matrices are Identical689
85Maximum Product Subarray II686
86Multiplication of Previous and Next680
87Subtraction of Two Matrices673
88Merge K Sorted Arrays and Print Sorted Output667
89Divide a string in N equal parts664
90Form Minimum Number from Given Sequence of D’s and I’s664
91Move All the Zeros to the End of the Given Array664
92Online Algorithm for Checking Palindrome in a Stream663
93Check whether two strings are anagram of each other656
94Remove recurring digits in a given number655
95Sort a stack using a temporary stack651
96Maximum Circular Subarray Sum649
97Sort a linked list that is sorted alternating ascending and descending644
98Subarray and Subsequence638
99Find the Minimum Element in a Sorted and Rotated Array636
100First Circular Tour to Visit all the Petrol Bunks632
101Move last element of the Linked List at first place632
102Compare two strings(linked lists)627
1033Sum Leetcode Solution627
104Largest Subarray with Equal Number of 0’s and 1’s626
105Maximum Element in an Array which is Increasing and then Decreasing626
106Palindrome Permutations of a String625
107Flattening a linked list623
108Palindromes in a given range620
109Majority Element618
110Minimum insertions to form a shortest palindrome617
111Pangram Checking616
112Run length encoding615
113Print all permutations with repetition612
114Elements Appear more than N/K times in Array611
115Minimum Characters to be Added at Front to Make String Palindrome608
116Most repeating character in a string605
117Two Sum Leetcode Solution601
118Rotate string to get lexicographically minimum string600
119Repeated Subsequence of Length Two or More596
120Merge a linked list into another at alternate positions595
121Rearrange a given linked list in-place594
122Remove all duplicates in a sorted linked list593
123Minimum number of Merge Operations to make an Array Palindrome593
124Print all anagrams together in a sequence of words587
125Reorder an Array According to the Given Indexes580
126Pancake Sorting Problem578
127Merge Overlapping Intervals II566
128Clone a Linked List with next and random pointer565
129Remove duplicates from a string565
130Longest Palindrome can be Formed by Removing or Rearranging Characters564
131Transpose of a Matrix564
132Smallest Palindrome after Replacement563
133Remove Extra Spaces from a String563
134Maximum Sum Increasing Subsequence559
135Removing Spaces from a String using stringstream559
136Size of The Subarray With Maximum Sum557
137Check if a given string is a rotation of a palindrome556
138Partition Problem551
139Generate all Binary Strings from Given Pattern545
140Check whether Strings are K Distance Apart or Not544
141Length of Longest valid Substring541
142Delete Last Occurrence538
143Check if Two given Strings are Isomorphic to each other535
144Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized533
145Insert Node in the Sorted Linked List531
146Program to Toggle all Characters in a String526
147Maximum difference between two elements such as larger element comes after smaller525
148Given string is interleaving of two other strings or not524
149Count Minimum Steps to Get the given Array514
150Number of Smaller Elements on Right Side512
151Check length of a String is Equal to the Number Appended at its Last511
152Check if all Rows of a Matrix are Circular Rotations of Each Other507
153Longest Common Prefix using Divide and Conquer506
154Find Pair with Given Difference506
155Merge sort better than quick sort for linked lists505
156Compare Two Version Numbers501
157Print all interleavings of given two strings496
158Find nth node of the Linked list from the end496
159Print Reverse of a string (Recursion)495
160Median of Two Sorted Arrays LeetCode Solution494
161Find a Fixed Point in a Given Array494
162Sort 0s 1s and 2s in an Array493
163Reorder Array Using Given Indexes492
164Reverse words in a given string490
165Find the Subarray of given length with Least Average484
166Merge two sorted linked lists such that merged list is in reverse order484
167Split linked list using alternate nodes481
168Print all Palindromic Partitions of a String475
169Print string of odd length in ‘X’ format470
170Find Element Using Binary Search in Sorted Array468
171Find K Length Subarray of Maximum Average465
172Swap Kth Node from beginning with Kth Node from End461
173Find Duplicates in an Array in Most Efficient Way457
174print all palindromic partitions454
175Shortest Superstring Problem453
176Check if String Follows Order of Characters by a Pattern or not450
177Maximum Length of Chain Pairs448
178Sort a String According to Another String446
179Flatten a multilevel linked list445
180Sorting a K Sorted Array438
181Program to add two binary digits431
182Recursively print all the sentences that can be formed from list of word lists427
183Find a Sorted Subsequence of size 3426
184Longest Common Prefix Using Binary Search II425
185Reverse a Linked List in groups425
186Caesar Cipher425
187Longest Span with same Sum in two Binary Arrays II425
188Find the two Numbers with Odd Occurrences in an Unsorted Array422
189Kth Non-repeating Character421
190Reverse a Singly Linked List (Iterative/Non-Recursive)419
191Check if String can Become Empty by Recursively Deleting given Substring414
192Longest Common Prefix Word by Word Matching409
193Rearrange a linked list in Zig-Zag409
194Rotate Image by 90 degrees405
195Permutations of a Given String Using STL404
196Perfect Reversible String403
197Pancake Sorting402
198Find First non-repeating character in a string400
199Merging Two Sorted Arrays400
2001`s and 2`s complement of binary number398
201Increasing Subsequence of Length three with Maximum Product394
202Maximum occurring character in a string393
203List items containing all characters of a given word391
204Find the point where a monotonically increasing function becomes positive first time390
205Four Elements that Sum to Given389
206Sort a linked list with 0s, 1s and 2s389
207Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes387
208Longest Common Prefix using Character by Character Matching385
209Palindrome string (number)382
210Count Number of Occurrences in a Sorted Array382
211Valid Parentheses LeetCode Solution380
212Delete N nodes after M379
213Minimum Characters to be Removed to Make a Binary String Alternate376
214Even Substring Count374
215Split a string374
216Recursive Implementation of atoi()371
217Convert a String that is Repetition of a Substring of Length K369
218Sorting the array of strings369
219Check if a Linked list of Strings form a Palindrome365
220Print Shortest Path to Print a String on Screen363
221Maximum Subarray Leetcode Solution361
222Convert string1 to string2 in one edit359
223Reverse a String using Stack359
224Print All Distinct Elements of the Array359
225Find the first Repeating Number in a Given Array357
226Nth Character in Concatenated Decimal String357
227Matrix Chain Multiplication using Dynamic Programming357
228Reverse a singly linked list recursively356
229wildcard character matching355
230Count the number of words355
231Lower Case To Upper Case352
232Can we reverse a linked list in less than O(n) time ?350
233Binary Tree to Doubly linked list347
234Sort Elements by Frequency II344
235Longest Common Subsequence with Permutations343
236Find the Lost Element From a Duplicated Array343
237Split Four Distinct Strings340
238Merge Two Sorted Arrays340
239Find middle of the Linked List335
240Roman to Integer Leetcode Solution334
241Count the Pairs at Same Distance as in English Alphabets334
242Toeplitz Matrix327
243Palindrome Permutation326
244Next Greater Element in an Array324
245Word Search Leetcode Solution324
246Move all negative elements to one side of array322
247N queen problem322
248Searching a node in a Binary Search Tree317
249Find Nth Node315
250Sudoku Solver315
251Find All Pairs With a Given Difference315
252Reverse Bits314
253First non Repeating Element314
254Print all Possible Ways to Break a String in Bracket Form313
255String(represents an integer) to value313
256Number of Islands LeetCode Solution313
257Count Pairs With Given Sum313
258Delete a Tree311
259Reverse a String311
260Triplet from three linked lists with given sum311
261Types of Binary Tree310
262Change Gender of a given String310
263Repeated Substring Pattern309
264How to Efficiently Implement k Stacks in a Single Array?308
265Meeting Rooms II LeetCode Solution307
266Fibonacci numbers306
267Number of sub-strings which recursively add up to 9305
268Delete a node under given conditions305
269Sort an array of strings305
270Reverse a linked list305
271Most Frequent Element in an Array304
272Longest Palindromic Substring LeetCode Solution304
273Min Stack303
274Cuckoo sequence program302
275Dijkstra Algorithm300
276Longest Common Extension298
277Binary Tree297
278House Robber Leetcode Solution296
279Remove spaces from a string296
280Max stack294
281Best Time to Buy and Sell Stock  II Leetcode Solution293
282Subset Leetcode292
283Word Search290
284Shuffle a given Array289
285KMP Algorithm288
286Remove middle points in a linked list of line segments288
287Plus One Leetcode Solution287
288Expression Evaluation286
289Find, second, frequent, character286
290Minimize the maximum difference between the heights286
291Combination Sum Leetcode Solution284
292Search Insert Position Leetcode Solution283
293Number Of 1 bits282
294Reverse words in a string282
295Evaluation of Postfix Expression280
296Pair of Positive Negative Values in an Array280
297Set Matrix Zeroes279
298Sliding Window Technique279
299Min Stack Leetcode Solution276
300Valid Palindrome Leetcode Solution276
301Rabin Karp Algorithm275
302Common elements in all rows of a given matrix273
303Backspace String Compare273
304Subarray with 0 sum273
305Sort linked which is sorted on absolute values272
306Merge Sorted Arrays Leetcode Solution270
307Clone a linked list with next and random pointer (Hashing)270
308Sqrt(x) Leetcode Solution268
309Delete middle element of a stack268
310Reversing a Queue267
311Implementation of Deque using Doubly Linked List266
312Contains Duplicate II Leetcode Solution265
313Count of index pairs with equal elements in an array264
314Product of array except self263
315Contains Duplicate263
316Tower Of Hanoi263
317Pascal Triangle Leetcode262
318String Compression262
319Reverse individual words262
320Combination Sum262
321Count subarrays with equal number of 1’s and 0’s262
322Find Top K (or Most Frequent) Numbers in a Stream261
323Intersection of Two Arrays II Leetcode Solution261
324Count Odd Numbers in an Interval Range Leetcode Solution260
325Minimum swaps required to bring all elements less than or equal to k together260
326Page Replacement Algorithms in Operating Systems260
327How to Delete a Linked List260
328Integer to Roman Leetcode Solution259
329Group Words With Same Set of Characters258
330Segregate even and odd numbers258
331Second Most Repeated Word in a Sequence257
332Postfix to Infix Conversion256
333Single Number Leetcode Solution256
334Bellman Ford Algorithm256
335Find sum of non-repeating elements (distinct) elements in an array256
336Sorting array using Stacks256
337Minimum Value to Get Positive Step by Step Sum Leetcode Solution255
338Sort elements by frequency255
339Sum of minimum and maximum elements of all subarrays of size k255
340Arithmetic Expression Evaluation254
341K-th Smallest Element in a Sorted Matrix254
342Add Binary Leetcode Solution254
343Smallest Subarray with k Distinct Numbers254
344Top K Frequent Words252
345Construct Binary Tree from Given Inorder and Preorder Traversals252
346Minimum operation to make all elements equal in array252
347Next Permutation252
348Pow(x, n) Leetcode Solution251
349Maximum Number of Balloons Leetcode Solution251
350Given two unsorted arrays find all pairs whose sum is x250
351Palindrome Linked List Leetcode Solution250
352Count subarrays having total distinct elements same as original array250
353Convex Hull Algorithm249
354Longest Common Prefix Leetcode Solution249
355Scramble String249
356First element occurring k times in an array248
357Special Number248
358Design a stack that supports getMin() in O(1) time and O(1) extra space248
359Longest Substring Without Repeating Characters LeetCode Solution248
360Kruskal Algorithm247
361Majority Element Leetcode Solution246
362Evaluate Division245
363Find Lucky Integer in an Array Leetcode Solution245
364Find duplicates in a given array when elements are not limited to a range245
365Permutations Leetcode Solution245
366Third Maximum Number Leetcode Solution244
367Spiral Matrix LeetCode Solution243
368Reversing the First K elements of a Queue243
369Maximum possible difference of two subsets of an array243
370Running Sum of 1d Array Leetcode Solution242
371Check if two arrays are equal or not242
372Number of Good Pairs Leetcode Solution242
373Prefix to Infix Conversion242
374Reverse a Number Using Stack242
375Minimum Path Sum241
376Fizz Buzz Leetcode241
377Huffman Coding241
378Maximum Subarray241
379Find Numbers with Even Number of Digits Leetcode Solution240
380Find the Town Judge Leetcode Solution240
381Maximal Square240
382Group Anagrams239
383Swap Nodes in Pairs Leetcode Solutions239
384Find the Closest Palindrome number238
385Minimum Absolute Difference Leetcode Solution238
386Minimum Steps to reach target by a Knight238
387Unique Paths238
388Count Primes Leetcode Solutions238
389Maximum Distance Between two Occurrences of Same Element in Array238
390Single Number238
391Sort Array by Increasing Frequency Leetcode Solution237
392Find top three repeated in array237
393Range Sum Query 2D – Immutable Leetcode Solution237
394Smallest Element Repeated Exactly K Times236
395Palindrome Substring Queries236
396Find Number of Employees Under every Employee236
397Cumulative Frequency of Count of Each Element in an Unsorted Array236
398Find the first repeating element in an array of integers236
399Sorting using trivial hash function235
400Remove Minimum Number of Elements Such That no Common Element Exist in both Array235
401Convert String To Int235
402Zigzag Conversion235
403Pascal’s Triangle II Leetcode Solution235
404Find All Numbers Disappeared in an Array Leetcode Solution235
405Power of Two Leetcode Solution234
406Count Substrings with equal number of 0s, 1s and 2s234
407Implement Stack and Queue using Deque234
408Sort Integers by The Number of 1 Bit Leetcode Solution234
409Leetcode Permutations234
410Matrix Diagonal Sum Leetcode Solution233
411Print all subarrays with 0 sum233
412How to Implement Stack Using Priority Queue or Heap?233
413Merge Two Sorted Lists Leetcode Solutions233
414Missing Number Leetcode Solution233
415Letter Case Permutation233
416Check if Array Contains Contiguous Integers With Duplicates Allowed233
417Length of the largest subarray with contiguous elements232
418Expression Contains Redundant Bracket or Not232
419House Robber II Leetcode Solution232
420Bipartite Graph232
421LRU Cache Implementation231
422Top K Frequent Elements231
423Prim’s Algorithm231
424Print All Distinct Elements of a Given Integer Array231
425Happy Number Leetcode Solution231
426Difference between highest and least frequencies in an array231
427Fizz Buzz231
428Subset sum problem230
429Subarray Sum Equals k230
430Unique Paths Leetcode Solution230
431Sort a stack using recursion230
432Maximum Depth of Binary Tree Leetcode Solution230
433Count pairs from two linked lists whose sum is equal to a given value230
434Decode String230
435Search in Rotated Sorted Array Leetcode Solution229
436Find Winner on a Tic Tac Toe Game Leetcode Solution229
437Find Median from data Stream229
438Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution229
439Find all pairs (a, b) in an array such that a % b = k229
440Coin Change 2 Leetcode Solution228
441Reverse a Stack Using Recursion228
442Check If N and Its Double Exist Leetcode Solution228
443Reverse Integer228
444Max Consecutive Ones Leetcode Solution228
445Subarrays with distinct elements228
446Nth Catalan Number227
447Capacity To Ship Packages Within D Days Leetcode Solution227
448How Many Numbers Are Smaller Than the Current Number Leetcode Solution226
449Monotonic Array LeetCode Solution226
450Find The Duplicate Number226
451Find the Difference Leetcode Solution226
452Find elements which are present in first array and not in second226
453Trapping Rain Water Leetcode Solution225
454Integer to English words225
455Text Justification LeetCode Solution224
456Reverse Vowels of a String Leetcode Solution224
457Edit Distance224
458Best Time to Buy and Sell Stock III Leetcode Solution224
459Find distinct elements common to all rows of a matrix224
460Floyd Warshall Algorithm224
461Pair with given product224
462Sum of Subarray Ranges Leetcode Solution224
463Subarray Sum Equals K LeetCode Solution224
464Priority Queue Using Singly Linked List224
465Valid Parenthesis String223
466Find Index of Closing Bracket for a Given Opening Bracket in an Expression223
467Subtract the Product and Sum of Digits of an Integer Leetcode Solution223
468Target Sum223
469Fibonacci Number LeetCode Solution223
470Remove Duplicates from Sorted Array Leetcode Solution223
471Reverse a String222
472Kth largest element in an Array Leetcode Solutions222
473Count and Say222
474Generate a String With Characters That Have Odd Counts Leetcode Solution221
475Longest subarray not having more than K distinct elements221
476Check if a given array contains duplicate elements within k distance from each other220
477Find four elements that sum to a given value (Hashmap)220
478Delete a Node from linked list without head pointer220
479Jump Game Leetcode Solution220
480Find Common Characters Leetcode Solution220
481Design Parking System Leetcode Solution220
482Find Minimum In Rotated Sorted Array220
483The K Weakest Rows in a Matrix Leetcode Solution220
484MiniMax Algorithm220
485Rearrange a binary string as alternate x and y occurrences220
486Longest Common Prefix using Trie220
487Prefix to Postfix Conversion220
488Shuffle String Leetcode Solution219
489Intersection of Two Arrays219
490Find any one of the multiple repeating elements in read only array219
491Sorting a Queue without Extra Space219
492The Stock Span Problem218
493Count number of triplets with product equal to given number218
494Find missing elements of a range218
495Word Ladder LeetCode Solution218
496Top View of Binary Tree218
497Flood Fill LeetCode218
498Multiply Strings Leetcode Solution218
499Shuffle the Array Leetcode Solution217
500Merge Two Sorted Linked Lists217
501Shortest Palindrome217
502Best Time to Buy and Sell Stock LeetCode Solution217
503Iterative Tower of Hanoi217
504Balanced Binary Tree Leetcode Solution217
505Degree of an array217
506Substring With Concatenation Of All Words217
507Iterative Inorder Traversal of a Binary Tree216
508Kids With the Greatest Number of Candies Leetcode Solution216
509Number of Steps to Reduce a Number to Zero Leetcode Solution216
510Find subarray with given sum (Handles Negative Numbers)216
511Priority Queue in C++216
512Excel Sheet Column Number Leetcode Solution216
513Next Greater Element I Leetcode Solution216
514Implement Stack using Queues215
515Concatenation of Array LeetCode Solution215
516K-th Distinct Element in an Array215
517Check for Balanced Parentheses in an Expression215
518Slowest Key Leetcode Solution215
519Move Zeroes LeetCode Solution215
520Count and Say Leetcode Solution215
521Valid Sudoku215
522Reverse Words in a String III LeetCode Solution215
523Longest Common Subsequence215
524Longest Common Prefix using Sorting214
525Postfix to Prefix Conversion214
526Peak Index in a Mountain Array214
527Max Area of Island214
528Minimum Knight Moves LeetCode Solution214
529Recursion214
530Sum of Left Leaves Leetcode Solutions214
531Kth Largest Element in a Stream Leetcode Solution213
532Find First and Last Position of Element in Sorted Array Leetcode Solution213
533Linked List Cycle II LeetCode Solution213
534Find the Duplicate Element213
535Convert array into Zig-Zag fashion213
536Implement a stack using single queue213
537Merge Overlapping Intervals213
538Find Sum of all unique sub-array sum for a given array212
539Minimum Delete Operations to make all Elements of Array Same212
540Largest Perimeter Triangle Leetcode Solution212
541Jewels and Stones Leetcode Solution212
542Arrange given numbers to form the biggest number212
543Container with Most Water212
544Minimum Moves to Equal Array Elements Leetcode Solution212
545Largest Sum Contiguous Subarray212
546Is Subsequence Leetcode Solution212
547Gold Mine Problem211
548Smallest Subarray With all Occurrences of a Most Frequent Element211
549Group Multiple Occurrence of Array Elements Ordered by first Occurrence211
550Check if a queue can be sorted into another queue using a stack211
551Excel Sheet Column Title Leetcode Solution211
552Isomorphic Strings Leetcode Solution210
553Next Greater Frequency Element210
554Hamming Distance210
555Contiguous Array Leetcode210
556Zigzag Conversion LeetCode Solution210
557Last Stone Weight210
558How to check if two given sets are disjoint?210
559Find N Unique Integers Sum up to Zero Leetcode Solution210
560Change the Array into Permutation of Numbers From 1 to N210
561Delete Node in a Linked List Leetcode Solution210
562Convert a normal BST to Balanced BST209
563Maximum sum rectangle in a 2D matrix209
564N-th Tribonacci Number Leetcode Solution209
565Minimum Bracket Reversals209
566Count the number of nodes at given level in a tree using BFS208
567Koko Eating Bananas Leetcode Solution208
568Best Time to Buy and Sell Stock208
569Mobile Numeric Keypad Problem208
570Summary Ranges Leetcode Solution208
571Shuffle an Array208
572Distribute Candies to People Leetcode Solution208
573Length of Last Word Leetcode Solution208
574Valid Anagrams207
575Implementation of Deque using circular array207
576Minimum Cost to Hire K Workers207
577Maximum Distance in Array207
5783Sum Closest LeetCode Solution206
579Trapping Rain Water LeetCode Solution206
580Shortest Path in a Grid with Obstacles Elimination LeetCode Solution206
581Maximum path sum in a triangle206
582Minimum number of subsets with distinct elements206
583Decode Ways206
584Find Words That Can Be Formed by Characters Leetcode Solution206
585Frog Jump Leetcode Solution206
586Remove All Occurrences of a Substring LeetCode Solution205
587First negative integer in every window of size k205
588Integer to Roman205
589Relative Sort Array Leetcode Solution205
590Number of Provinces Leetcode Solution205
591Find if an Expression has Duplicate Parenthesis or Not205
592Rotate Image LeetCode Solution205
593Build Array From Permutation Leetcode Solution205
594Combinations Leetcode Solution204
595Minimum Operations to convert X to Y204
596Longest Increasing Subsequence204
597Delete consecutive same words in a sequence204
59801 Matrix LeetCode Solution204
599LRU Cache LeetCode Solution204
600Island Perimeter Leetcode Solution203
601Minimum number of distinct elements after removing m items203
602Maximum difference between first and last indexes of an element in array203
603Smallest Good Base203
604Sieve of Eratosthenes203
605Count all subsequences having product less than K203
606Word Pattern203
607Iterative Method to find Height of Binary Tree203
608Maximum Number of Occurrences of a Substring Leetcode Solution203
609Sort Characters By Frequency LeetCode Solution202
610Assign Cookies Leetcode Solution202
611Find minimum difference between any two elements202
612XOR Operation in an Array Leetcode Solution202
613Convert Sorted Array to Binary Search Tree Leetcode Solution201
614Bubble sort using two Stacks201
615Rotate List Leetcode Solution201
616Reverse a stack without using extra space in O(n)201
617Stone Game LeetCode201
618Non-overlapping sum of two sets201
619GCD Of Two Numbers201
620Find the smallest positive integer value that cannot be represented as sum of any subset of a given array201
621Minimum insertions to form a palindrome with permutations allowed201
622Remove Linked List Elements Leetcode Solution201
623Insert Interval Leetcode Solution201
624Tracking current Maximum Element in a Stack200
625Sum of f(a[i], a[j]) over all pairs in an array of n integers200
626The Knapsack Problem200
627Same Tree LeetCode Solution200
628Applications of Breadth First Search and Depth First Search200
629Find Largest d in Array such that a + b + c = d199
630Defanging an IP Address Leetcode Solution199
631Find the Duplicate Number LeetCode Solution199
632Permutation in String Leetcode Solution199
633Reorganize String199
634Isomorphic Strings199
635Unique Binary Search Trees199
636Distance Between Bus Stops Leetcode Solution198
637K Empty Slots198
638How to Create Mergable Stack?198
639Count Good Nodes in Binary Tree Leetcode Solution198
640Maximum Number of Chocolates to be Distributed Equally Among k Students198
641License Key Formatting Leetcode Solution198
642Optimal Account Balancing LeetCode Solution198
643Printing brackets in Matrix Chain Multiplication Problem198
644Longest Increasing Path in a Matrix LeetCode Solution198
645First Unique Character in a String LeetCode Solution198
646Letter Combinations of a Phone Number197
647Form minimum number from given sequence197
648Employee Free Time LeetCode Solution197
649Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions196
650Minimum Depth of Binary Tree Leetcode Solution196
651Convert an array to reduced form196
652Replace Elements with Greatest Element on Right Side Leetcode Solution196
653Sort Array By Parity LeetCode Solution195
654Word Wrap Problem195
655Find Pair with Greatest Product in Array195
656Find pairs with given sum such that elements of pair are in different rows195
657Strobogrammatic Number LeetCode Solution195
658Check If It Is a Straight Line Leetcode Solution195
659House Robber195
660Painting Fence Algorithm195
661Merge Two Balanced Binary Search Trees195
662Robot Room Cleaner Leetcode Solution195
663Reducing Dishes LeetCode Solution195
664Partition Labels LeetCode Solution194
665Convert a Number to Hexadecimal Leetcode Solution194
666Largest subarray with equal number of 0s and 1s194
667K Empty Slots LeetCode194
668Queries for counts of array elements with values in given range194
669Moving Average from Data Stream Leetcode Solution194
670Maximum Consecutive Numbers Present in an Array194
671Segregate 0s and 1s in an Array194
672Kth Missing Positive Number Leetcode Solution194
673String to Integer (atoi) LeetCode Solution193
674Find Maximum Level sum in Binary Tree193
675Maximum Product of Two Elements in an Array Leetcode Solution193
676Longest Substring with At Most K Distinct Characters LeetCode Solution193
677Valid Palindrome II Leetcode Solution193
678Longest Substring with At Least K Repeating Characters LeetCode Solution193
679Power of Four Leetcode Solution192
680Print the Fibonacci numbers in reverse order192
681Best Time to Buy and Sell Stock with Cooldown Leetcode Solution192
682Reservoir Sampling192
683Distance of nearest cell having 1 in a binary matrix192
684Find the node with minimum value in a Binary Search Tree192
685Partition Array Into Three Parts With Equal Sum Leetcode Solution192
686Dynamic Programming Basics192
687Valid Palindrome192
688Coin Change Problem192
689Longest Span with same Sum in two Binary arrays191
690Find unique character in a string191
691Remove Invalid Parentheses Leetcode Solution191
692Find the Smallest Divisor given a Threshold Leetcode Solution191
693String Compression LeetCode Solution191
694Find the Distance Value Between Two Arrays Leetcode Solution191
695Sum of All Odd Length Subarrays Leetcode Solution191
696Check If Two String Arrays are Equivalent Leetcode Solution191
697Path With Maximum Minimum Value LeetCode Solution190
698Number of Dice Rolls With Target Sum LeetCode Solution190
699Find the largest multiple of 3190
700Inorder Successor of a node in Binary Tree190
701Unique Paths II Leetcode Solution190
702Reverse Only Letters LeetCode Solution190
703Generate all possible sorted arrays from alternate elements of two given sorted arrays190
704Find Leaves of Binary Tree LeetCode Solution190
705Numbers with prime frequencies greater than or equal to k190
706Wiggle Sort190
707To Lower Case Leetcode Solution190
708Flipping an Image LeetCode Solution190
709Binary Tree Maximum Path Sum LeetCode Solution190
710Edit Distance LeetCode Solution189
711Subset Sum Leetcode189
712Factorial Trailing Zeroes Leetcode Solution189
713Increasing Decreasing String Leetcode Solution189
714Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest189
715Stack Permutations (Check if an array is stack permutation of other)189
716Delete Nth node from the end of the given linked list189
717Maximum Number of Coins You Can Get Leetcode Solution189
718Permutation Sequence LeetCode Solution188
719Snakes and Ladders LeetCode Solution188
720Find if Path Exists in Graph Leetcode Solution188
721Non-decreasing Array LeetCode Solution188
722Perform String Shifts Leetcode188
723Merge Two Binary Trees LeetCode Solution188
724Find whether an array is subset of another array188
725Bulb Switcher LeetCode Solution188
726Lucky Numbers in a Matrix Leetcode Solution188
727Reversing a Queue using Recursion188
728Sort Array by Increasing Frequency Leetcode Solution188
729Count quadruples from four sorted arrays whose sum is equal to a given value x188
730Race Car LeetCode Solution188
731BFS vs DFS for Binary Tree187
732Majority Element II Leetcode Solution187
733Maximum 69 Number Leetcode Solution187
734Find Maximum Depth of Nested Parenthesis in a String187
735Ugly Number Leetcode Solution187
736Binary Tree Zigzag Level Order Traversal LeetCode Solution187
737Populating Next Right Pointers in Each Node187
738Valid Perfect Square Leetcode Solution187
739Student Attendance Record I Leetcode Solution186
740Tiling Problem186
741Recover Binary Search Tree186
742Number of NGEs to the Right186
743Merge Sorted Array LeetCode Solution186
744Remove brackets from an algebraic string containing + and – operators186
745String comparison containing wildcards186
746Best Meeting Point LeetCode Solution186
747Evaluate Reverse Polish Notation LeetCode Solution186
748Keyboard Row Leetcode Solution186
749Minimum Cost For Tickets Leetcode Solution186
750Maximum Length of a Concatenated String with Unique Characters Leetcode Solution186
751Base 7 Leetcode Solution186
752Print a Binary Tree in Vertical Order185
753Restore IP Addresses Leetcode Solution185
754Split a String in Balanced Strings Leetcode Solution185
755Valid Number185
756Binary Tree zigzag level order Traversal185
757Word Pattern LeetCode Solution185
758Symmetric Tree Leetcode Solution185
759Elements to be added so that all elements of a range are present in array185
760Morris Traversal185
761Maximum Product of Three Numbers LeetCode Solution185
762Find All Possible Recipes from Given Supplies LeetCode Solution185
763Finding K closest element185
764Program for Bridge and Torch problem185
765Find Median from Data Stream LeetCode Solution185
766k-th missing element in increasing sequence which is not present in a given sequence185
767Rank Transform of an Array Leetcode Solution185
768Binomial Coefficient184
769Construct BST from given Preorder Traversal184
770Brick Wall LeetCode Solution184
771Check If Array Pairs Are Divisible by k LeetCode Solution184
772Priority Queue using doubly linked list184
773Maximum Profit in Job Scheduling Leetcode Solution184
774Partition to K Equal Sum Subsets Leetcode Solution184
775Find All Duplicates in an Array LeetCode Solution184
776Regular Expression Matching184
777N-Queens LeetCode Solution184
778Special Array With X Elements Greater Than or Equal X Leetcode Solution184
779Add and Search Word – Data structure design LeetCode184
780Check if Two Expressions With Brackets are Same184
781Decompress Run-Length Encoded List Leetcode Solution183
782Growable array based stack183
783Number of Days Between Two Dates LeetCode Solution183
784Sorted Linked List to Balanced BST183
785Minimum Distance Between BST Nodes Leetcode Solution183
786Minimize Maximum Pair Sum in Array LeetCode Solution183
787Jump Game183
788Search in a Binary Search Tree Leetcode Solution183
789Hamming Distance Leetcode Solution183
790Check for Palindrome after every character replacement Query182
791Minimum Height Trees182
792Kth ancestor of a node in binary tree182
793Minimum sum of multiplications of n numbers182
794Maximum Depth of N-ary Tree Leetcode Solution182
795Total Numbers With no Repeated Digits in a Range182
796Maximum Difference Between Increasing Elements LeetCode Solution182
797Nearest Exit from Entrance in Maze LeetCode Solution182
798Invert Binary Tree LeetCode Solution182
799Largest rectangular sub-matrix whose sum is 0182
800One Edit Distance LeetCode Solution182
801Form Minimum Number From Given Sequence182
802Top K Frequent Words LeetCode Solution182
803Sort an array according to the order defined by another array182
804Largest Rectangle in Histogram LeetCode Solution182
805Merge K Sorted Linked Lists182
806Minimum Time Visiting All Points Leetcode Solution181
807Queue based approach for first non-repeating character in a stream181
808Balanced Expression with Replacement181
809Final Prices With a Special Discount in a Shop Leetcode Solution181
810Identify and Mark Unmatched Parenthesis in an Expression181
811Number of Islands II LeetCode Solution181
812Remove Nth Node From End of List Leetcode Solution181
813Circular Queue181
814Maximum Nesting Depth of the Parentheses Leetcode Solution180
815Longest Subarray Having Count of 1s One More than Count of 0s180
816Repeated Substring Pattern LeetCode Solution180
817Relative Ranks Leetcode Solution180
818Nested List Weight Sum II LeetCode Solution180
819Transpose Graph180
820Linked List Cycle180
821Diagonal Traversal of Binary Tree180
822Count items common to both the lists but with different prices179
823Given an Array of Pairs Find all Symmetric Pairs in it179
824Minimum time required to rot all oranges179
825Minimum Number of Taps to Open to Water a Garden LeetCode Solution179
826Crawler Log Folder Leetcode Solution179
827Minimum Swaps to Make Strings Equal Leetcode Solution179
828Deletion in a Binary Tree179
829Search a 2D Matrix II Leetcode Solution179
830Subarray Product Less Than K LeetCode Solution178
831Number Complement Leetcode Solution178
832Course Schedule II – LeetCode178
833Clone Graph LeetCode Solution178
834Permutation Coefficient178
835Minimum Jumps to Reach Home LeetCode Solution178
836Split Array Into Consecutive Subsequences178
837Daily Temperatures Leetcode Solution178
838Sort Array By Parity II Leetcode Solution178
839Binary Search Tree Search and Insertion177
840A Space Optimized DP solution for 0-1 Knapsack Problem177
841Check if stack elements are pairwise consecutive177
842Subsequence of Size K With the Largest Even Sum LeetCode Solution177
843Check if an Array is Stack Sortable177
844Insert Delete GetRandom177
845Find Maximum Sum Possible Equal Sum of Three Stacks177
846Iterative Preorder Traversal177
847LCS (Longest Common Subsequence) of three strings177
848Lemonade Change Leetcode Solution177
849Find all permuted rows of a given row in a matrix177
850Missing Element in Sorted Array LeetCode Solution177
851Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution177
852Reorder Data in Log Files LeetCode Solution177
853Last Stone Weight II LeetCode Solution177
854Distinct adjacent elements in an array177
855Count Distinct Elements in Every Window of Size K176
856Minimum number of jumps to reach end176
857Check if a given array can represent Preorder Traversal of Binary Search Tree176
858Sliding Window Maximum176
859Valid Parentheses Leetcode Solution176
860Subset with sum divisible by m176
861Design Browser History LeetCode Solution176
862Tree Traversal (Preorder, Inorder & Postorder)176
863Guess Number Higher or Lower LeetCode Solution176
864Union and Intersection of two Linked Lists175
865Interval Tree175
866Minimum Sum Path in a Triangle175
867Remove Duplicates from Sorted List II175
868Path with maximum average value175
869An Interesting Method to generate Binary Numbers from 1 to n175
870Remove Duplicates from Sorted List LeetCode Solution175
871Can Place Flowers LeetCode Solution175
872Design a Stack With Increment Operation Leetcode Solution175
873Convert BST to Min Heap175
874Partition List Leetcode Solution175
875Alien Dictionary LeetCode Solution175
876Get Maximum in Generated Array Leetcode Solution174
877Minimum swaps to make sequences increasing174
878Spiral Matrix II Leetcode Solution174
879Brightest Position on Street LeetCode Solution174
880Minesweeper LeetCode Solution174
881Dividing Array into Pairs With Sum Divisible by K174
882Count ways to reach the nth stair using step 1, 2 or 3174
883Find the subarray with least average174
884Sequences of given length where every element is more than or equal to twice of previous174
885Infix to Postfix174
886Sorted Array to Balanced BST173
887Water Bottles Leetcode Solution173
888GCDs of given index ranges in an array173
889Check whether a given Binary Tree is Complete or not173
890Sum of nearest smaller and greater number173
891Least Number of Unique Integers after K Removals Leetcode Solution173
892Friends Pairing Problem173
893Find all triplets with zero sum173
894Number of Distinct Islands Leetcode Solution173
895Find the Only Repetitive Element Between 1 to N-1173
896Maximum size subarray sum equals k173
897Sort Colors173
898Level order Traversal in Spiral Form173
899Maximum Score After Splitting a String Leetcode Solution173
900Pattern Occurrences using Stack173
901Find distance between two nodes of a Binary Tree173
902Diagonal Traverse LeetCode Solution173
903Guess Number Higher or Lower II173
904Matrix Chain Multiplication173
905Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i173
906Range sum queries without updates172
907Shortest Word Distance Leetcode Solution172
908Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution172
909Check if any two intervals overlap among a given set of intervals172
910Range LCM Queries172
911Lexicographical Numbers Leetcode Solution172
912Insert into a Binary Search Tree Leetcode Solution172
913Delete And Earn172
914Set Matrix Zeroes Leetcode Solution172
915All Unique Triplets that Sum up to a Given Value171
916Diagonal Traversal LeetCode Solution171
917Median of Two Sorted Arrays171
918Iterative Postorder Traversal Using Two Stacks171
919A program to check if a binary tree is BST or not171
920Averages of Levels in Binary Tree171
921Count Negative Numbers in a Sorted Matrix LeetCode Solution171
922Robot Bounded In Circle LeetCode Solution171
923Alien Dictionary171
924Time Based Key-Value Store LeetCode Solution171
925Destination City Leetcode Solution171
926Difference Array | Range update query in O(1)171
927Construct the Rectangle Leetcode Solution170
928Check if the given array can represent Level Order Traversal of Binary Search Tree170
929Rearrange an Array Such that arr[i] is equal to i170
930Binary Tree Longest Consecutive Sequence LeetCode Solution170
931Three way partitioning of an array around a given range170
932My Calendar I LeetCode Solution170
933Construct Complete Binary Tree from its Linked List Representation170
934Rearrange Spaces Between Words Leetcode Solution170
935Merge Two Sorted Lists Leetcode169
936Number of Equivalent Domino Pairs Leetcode Solution169
937Product of Array Except Self LeetCode Solution169
938Find Common Characters Leetcode Solution169
939Intersection of Two Linked Lists LeetCode Solution169
940Maximum Frequency Stack Leetcode Solution169
941Convert Sorted List to Binary Search Tree169
942Spiral Matrix III LeetCode Solution169
943Trim a Binary Search Tree169
944Vertical sum in a given binary tree169
945Count Submatrices With All Ones LeetCode Solution169
946Palindrome Partitioning Leetcode Solution169
947K’th Largest Element in BST when modification to BST is not allowed169
948Queue using Stacks169
949Special Positions in a Binary Matrix Leetcode Solution169
950Count Subarrays with Same Even and Odd Elements169
951Three Consecutive Odds Leetcode Solution168
952Binary array after M range toggle operations168
953Analyze User Website Visit Pattern LeetCode Solution168
954Remove Duplicates from Sorted List II LeetCode Solution168
955Largest area rectangular sub-matrix with equal number of 1’s and 0’s168
956Strongly Connected Component168
957Word Break168
958Minimum Height Trees LeetCode Solution168
959BFS for Disconnected Graph168
960Climbing stairs167
961Sign of the Product of an Array LeetCode Solution167
9624Sum167
963Kth Smallest Element in a BST Leetcode Solution167
964Construct BST from its given Level Order Traversal167
9653 Sum167
966Queries for GCD of all numbers of an array except elements in a given range167
967Longest Palindromic Subsequence167
968Create Maximum Number167
969Combination Sum IV LeetCode Solution166
970Symmetric Tree166
971Stone Game II Leetcode166
972Merging Intervals166
973Count Primes in Ranges166
974Maximum Product Subarray166
975Count subarrays where second highest lie before highest166
976Unique Paths II166
977Count pair with Given Sum166
978Maximize Sum of Array after K Negations Leetcode Solution166
979Longest subsequence such that difference between adjacents is one166
980Number of palindromic paths in a matrix166
981Find Maximum of Minimum for Every Window Size in a Given Array165
982Design Hit Counter LeetCode Solution165
983Reverse Nodes in K-Group165
984Depth First Search (DFS) for a Graph165
985Longest Nice Substring LeetCode Solution165
986Serialize and Deserialize Binary Tree165
987Breadth First Search (BFS) for a Graph165
988Print Fibonacci sequence using 2 variables165
989The Maze III LeetCode Solution165
990Largest Number Leetcode Solution165
991Maximum Product of Indexes of Next Greater on Left and Right164
992Maximum Length of Repeated Subarray164
993Find the First Circular Tour that visits all the Petrol Pumps164
994Can Make Arithmetic Progression From Sequence Leetcode Solution164
995Binary Search Tree Delete Operation164
996Valid Boomerang Leetcode Solution164
997Asteroid Collision LeetCode Solution164
998Find number of pairs in an array such that their XOR is 0164
999K Closest Points to Origin Leetcode Solution163
1000Kth Smallest Element in a Sorted Matrix LeetCode Solution163
1001Next Permutation Leetcode Solution163
1002K maximum sums of overlapping contiguous sub-arrays163
1003Count pairs from two sorted arrays whose sum is equal to a given value x163
1004Palindrome Partitioning163
1005String Matching in an Array Leetcode Solution163
1006Consecutive Characters LeetCode Solution163
1007Graph Valid Tree LeetCode Solution163
1008Scramble String LeetCode Solution163
1009Maximum Subarray Sum Excluding Certain Elements163
1010Collect maximum points in a grid using two traversals162
1011Level Order Traversal of Binary Tree162
1012Length of Longest Fibonacci Subsequence162
1013Validate Binary Search Tree162
1014Minimum Index Sum of Two Lists162
1015Maximum Sum of 3 Non-Overlapping Subarrays162
1016Decrypt String from Alphabet to Integer Mapping Leetcode Solution162
1017Shortest Completing Word Leetcode Solution162
1018Find the Difference Leetcode Solution162
1019Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space162
1020Balanced Binary Tree162
1021Find postorder traversal of BST from preorder traversal162
1022Height of a generic tree from parent array162
1023The Painter’s Partition Problem162
1024Find Duplicate Subtrees161
1025Maximum Number of Ways to Partition an Array LeetCode Solution161
1026Merge Sort161
1027Segment Tree161
1028Invalid Transactions LeetCode Solution161
1029Generate Parentheses Leetcode Solution161
1030Largest divisible pairs subset161
1031Available Captures for Rook Leetcode Solution161
1032Maximum difference between frequency of two elements such that element having greater frequency is also greater161
1033Maximum length subsequence with difference between adjacent elements as either 0 or 1161
1034Newman-Conway Sequence161
1035Print Next Greater Number of Q queries161
1036Construct Binary Tree from given Parent Array representation160
1037Boolean Parenthesization Problem160
1038Insertion in a Binary Tree160
1039Construction of Longest Increasing Subsequence (N log N)160
1040Advantages of BST over Hash Table160
1041Next Greater Element III LeetCode Solution160
1042First missing positive160
1043Number Of Longest Increasing Subsequence160
1044Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’160
1045Remove Duplicates from Sorted Array II Leetcode Solution160
1046Find a Peak Element II LeetCode Solution160
1047Make The String Great Leetcode Solution160
1048Binary Search Tree160
1049Largest Substring Between Two Equal Characters Leetcode Solution160
1050Custom Sort String Leetcode Solution160
1051Compute nCr % p159
1052Count minimum steps to get the given desired array159
1053Move all negative elements to end in order with extra space allowed159
1054Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution159
1055Boundary Traversal of binary tree159
1056Friends Of Appropriate Ages LeetCode Solution159
1057Iterative Depth First Traversal of Graph159
1058Rearrange array such that even positioned are greater than odd159
1059Maximum subsequence sum such that no three are consecutive158
1060Build an Array With Stack Operations Leetcode Solution158
1061Path Sum II LeetCode Solution158
1062Subarrays with K Different Integers Leetcode Solution158
1063Rearrange array such that even index elements are smaller and odd index elements are greater158
1064Largest BST Subtree LeetCode Solution158
1065Bitwise AND of Numbers Range LeetCode Solution158
1066Double the first element and move zero to end158
1067Kill Process LeetCode Solution158
1068Defanging an IP Address LeetCode Solution157
1069Recover Binary Search Tree Leetcode Solution157
1070Employee Importance LeetCode Solution157
1071Morris Inorder Traversal157
1072Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution157
1073Find Peak Element157
1074Minimum Size Subarray Sum157
1075Remove Palindromic Subsequences Leetcode Solution157
1076Regular Expression Matching Regular Expression Matching LeetCode Solution157
1077Level order traversal using two Queues157
1078Lowest Common Ancestor156
1079Maximum weight transformation of a given string156
1080Add two numbers156
1081Smallest Common Region Leetcode Solution156
1082Print Right View of a Binary Tree156
1083Find maximum difference between nearest left and right smaller elements156
1084Partition Equal Subset Sum156
1085Palindrome Permutation LeetCode Solution156
1086Longest Bitonic Subsequence155
1087Palindromic Substrings Leetcode Solution155
1088Remove duplicates from sorted array155
1089Super Ugly Number155
1090Number of Closed Islands Leetcode Solution155
1091Ugly Number II LeetCode Solution155
1092Ugly Numbers155
1093Increasing Triplet Subsequence LeetCode Solution155
1094Implement Trie (Prefix Tree) Leetcode Solution155
1095Maximize Distance to Closest Person LeetCode Solution155
1096Binary Tree Right Side View LeetCode Solution155
1097Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution154
1098Populating Next Right Pointers in Each Node Leetcode Solution154
1099Find whether a subarray is in form of a mountain or not154
1100Bus Routes Leetcode Solution154
1101Valid Tic-Tac-Toe State LeetCode Solution154
1102Sum of Even Numbers After Queries154
1103Path Sum154
1104Thousand Separator Leetcode Solution153
1105Moser-de Bruijn Sequence153
1106Reformat The String Leetcode Solution153
1107Divisible Pairs Counting153
1108Find Three Element From Different Three Arrays Such That a + b + c = sum153
1109Print all triplets in sorted array that form AP153
1110Search in Sorted Rotated Array153
1111Binary Tree Data Structure153
1112Number of siblings of a given Node in n-ary Tree153
1113Find the minimum distance between two numbers153
1114Cells with Odd Values in a Matrix LeetCode Solution152
1115Number of Students Doing Homework at a Given Time Leetcode Solution152
1116Kth Smallest Product of Two Sorted Arrays LeetCode Solution152
1117Level of Each node in a Tree from source node152
1118Count Largest Group Leetcode Solution152
1119Find Smallest Range Containing Elements from k Lists152
1120Day of the Year Leetcode Solution152
1121Mean of Array After Removing Some Elements Leetcode Solution152
1122Products of ranges in an array151
1123Root to Leaf path with target sum Leetcode Solutions151
1124Clone a Binary Tree with Random Pointers151
1125Distinct Subsequences151
1126Iterative method to find ancestors of a given binary tree151
1127Serialize and Deserialize Binary Tree LeetCode Solution151
1128Search Insert Position151
1129Longest Increasing Consecutive Subsequence150
1130Topological Sorting150
1131Third Maximum Number Leetcode Solution150
1132Prime Palindrome LeetCode Solution150
1133Minimum Absolute Difference in BST Leetcode Solution150
1134Compare Strings by Frequency of the Smallest Character Leetcode Solution150
1135Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution150
1136Constant time range add operation on an array150
1137Find maximum length Snake sequence150
1138Convert BST into a Min-Heap without using array149
1139Queries for Number of Distinct Elements in a Subarray149
1140Maximum Product Subarray149
1141Bottom View of a Binary Tree149
1142Construct K Palindrome Strings LeetCode Solution149
1143Maximum Depth Of Binary Tree149
1144Longest Repeated Subsequence149
1145Priority Queue148
1146Count even length binary sequences with same sum of first and second half bits148
1147Maximum Product of Splitted Binary Tree LeetCode Solution148
1148Web Crawler LeetCode Solution148
1149Rotate Array148
1150Diameter of N-Ary Tree LeetCode Solution148
1151Print modified array after executing the commands of addition and subtraction148
1152Minimum sum of squares of character counts in a given string after removing k characters148
1153Longest Subarray of 1’s After Deleting One Element LeetCode Solution148
1154Write Code to Determine if Two Trees are Identical147
1155Golomb sequence147
1156Closest Binary Search Tree Value Leetcode Solution147
1157Minimum Score Triangulation of Polygon Leetcode Solution147
1158Find a sorted subsequence of size 3 in linear time147
1159Cutting a Rod147
1160Search an Element in Sorted Rotated Array147
1161Subset Sum Problem in O(sum) space147
1162Find Largest Value in Each Tree Row LeetCode Solution147
1163Delete Nodes and Return Forest Leetcode Solution147
1164Closest Leaf in a Binary Tree LeetCode Solution146
1165Swap Nodes In Pairs146
1166Search Suggestions System LeetCode Solution146
1167Reformat Date LeetCode Solution146
1168Matchsticks to Square Leetcode Solution146
1169Maximize sum of consecutive differences in a circular array146
1170Minimum Cost to Move Chips to The Same Position LeetCode Solution146
1171Possible Bipartition LeetCode Solution145
1172Minimum Moves to Equal Array Elements LeetCode Solution145
1173Minimum Sideway Jumps LeetCode Solution145
1174Decision Tree145
1175K’th Largest element in BST using constant extra space145
1176Red-Black Tree Introduction145
1177Contiguous Array LeetCode Solution145
1178Count Pairs Whose Products Exist in Array145
1179Transform a BST to Greater sum Tree145
1180Kth Smallest Number in Multiplication Table Leetcode Solution145
1181Given a binary tree, how do you remove all the half nodes?145
1182Minimum Swaps To Make Sequences Increasing LeetCode Solution145
1183Reverse a Path in BST using Queue144
1184Sum of Left Leaves LeetCode Solution144
1185Binary Tree to Binary Search Tree Conversion144
1186Maximum Value at a Given Index in a Bounded Array LeetCode Solution144
1187First Bad Version144
1188Merge two BSTs with limited extra space144
1189Decrease Elements To Make Array Zigzag LeetCode Solution144
1190Find the smallest binary digit multiple of given number144
1191Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution144
1192Path Crossing Leetcode Solution144
1193Check Array Formation Through Concatenation Leetcode Solution144
1194Replace two consecutive equal values with one greater143
1195Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution143
1196Perfect Squares LeetCode Solution143
1197Print n terms of Newman-Conway Sequence143
1198Maximum number of segments of lengths a, b and c143
1199Valid Triangle Number143
1200Maximum Binary Tree143
1201Maximum sum of pairs with specific difference143
1202Concatenation of Array LeetCode Solution142
1203Convert Sorted Array to Binary Search Tree LeetCode Solutions142
1204Number of Orders in the Backlog Leetcode Solution142
1205Divide Two Integers Leetcode Solution142
1206Factorial Trailing Zeroes LeetCode Solution142
1207Maximum sum bitonic subarray142
1208Queue Reconstruction by Height142
1209Sliding Window Median Leetcode Solution142
1210Swapping Nodes in a Linked List Leetcode Solution141
1211New 21 Game141
1212Valid Perfect Square LeetCode Solution141
1213Lowest Common Ancestor in Binary Search Tree140
1214Maximum sum of a path in a Right Number Triangle140
1215Lowest Common Ancestor of a Binary Tree Leetcode Solution140
1216Integer Break LeetCode Solution140
1217Champagne Tower LeetCode Solution140
1218Kth Smallest Element in a BST140
1219How to print maximum number of A’s using given four keys140
1220Moving Stones Until Consecutive Leetcode Solution139
1221Flatten 2D Vector LeetCode Solution139
1222Array Queries for multiply replacements and product139
1223Guess The Word139
1224Longest Common Prefix Using Word by Word Matching139
1225Merge k Sorted Lists Leetcode Solution139
1226Find minimum number of merge operations to make an array palindrome139
1227Queries on Probability of Even or Odd Number in given Ranges139
1228Maximum Array from Two given Arrays Keeping Order Same138
1229Check if all levels of two Binary Tree are anagrams or not138
1230Range Sum Query using Sparse Table138
1231Mean of range in array138
1232Graph and its representation138
1233Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution138
1234LRU Cache Leetcode Solution137
1235Range Queries for Longest Correct Bracket Subsequence137
1236Print modified array after multiple array range increment operations137
1237Find Minimum in Rotated Sorted Array II LeetCode Solution137
1238Maximize Elements Using Another Array137
1239Maximum Sum Increasing Subsequence137
1240BST to a Tree with Sum of all Smaller Keys137
1241Missing Number137
1242Design Skiplist LeetCode Solution137
1243Contiguous Array137
1244Bold Words in String LeetCode Solution136
1245Largest Plus Sign Leetcode Solution136
1246Maximum Product Subarray136
1247Min Cost Climbing Stairs LeetCode Solution136
1248Write a function to get the intersection point of two Linked Lists136
1249Count Subsets Having Distinct Even Numbers136
1250Minimum Remove to Make Valid Parentheses LeetCode Solution136
1251Graph Cloning135
1252Check in binary array the number represented by a subarray is odd or even135
1253The kth Factor of n Leetcode Solution135
1254Find k-th smallest element in BST (Order Statistics in BST)134
1255Power of Two134
1256Different Ways to Add Parentheses Leetcode Solution134
1257Arithmetic Slices II – Subsequence LeetCode Solution134
1258Check if each internal node of a BST has exactly one child134
1259Parallel Courses II LeetCode Solution134
1260Check for Identical BSTs without building the trees133
1261Check if two nodes are on the same path in a Tree133
1262Minimum Time to Collect All Apples in a Tree LeetCode Solution133
1263Symmetric Tree LeetCode Solution Leetcode Solution132
1264Image Overlap LeetCode Solution132
1265Check Completeness of a Binary Tree LeetCode Solution132
1266Smallest Range II Leetcode Solution132
1267Print Ancestors of a Given Binary Tree Node Without Recursion132
1268Excel Sheet Column Title LeetCode Solution131
1269Verify Preorder Serialization of a Binary Tree131
1270Orderly Queue LeetCode Solution131
1271Longest Substring Without Repeating Characters Leetcode Solution130
1272Koko Eating Bananas LeetCode Solution130
1273Next greater element130
1274Arranging Coins Leetcode Solution129
1275Merge Sorted Array129
1276Largest Submatrix With Rearrangements LeetCode Solution128
1277Vertical Order Traversal of Binary Tree LeetCode Solution128
1278Count and Toggle Queries on a Binary Array128
1279Number of elements less than or equal to a given number in a given subarray128
1280Palindrome Number LeetCode Solution127
1281Array Nesting Leetcode Solution127
1282Palindrome Partitioning127
1283Newman–Shanks–Williams prime126
1284Check If a String Can Break Another String Leetcode Solution126
1285Queries for Decimal Values of Subarrays of a Binary Array125
1286Insert Delete GetRandom O(1) Leetcode Solution125
1287Maximum product of an increasing subsequence125
1288Add Two Numbers II Leetcode Solution125
1289Find the Winner of the Circular Game LeetCode Solution125
1290Peeking Iterator LeetCode Solution125
1291Check if X can give change to every person in the Queue125
1292Range Minimum Query (Square Root Decomposition and Sparse Table)124
1293Find maximum average subarray of k length124
1294Encoded String With Shortest Length LeetCode Solution122
1295Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution122
1296Continuous Subarray Sum LeetCode Solution121
1297Check given array of size n can represent BST of n levels or not121
1298Number of indexes with equal elements in given range120
1299Binary Tree to Binary Search Tree Conversion using STL set120
1300Jump Game IV LeetCode Solution120
1301Reach a Number LeetCode Solution119
1302Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution119
1303Minimum Number of People to Teach LeetCode Solution119
1304Random Pick Index LeetCode Solution119
1305Convert a BST to a Binary Tree such that sum of all greater keys is added to every key118
1306Minimum Total Space Wasted With K Resizing Operations LeetCode Solution117
1307Convert to Base -2 LeetCode Solution116
1308Design A Leaderboard Leetcode Solution115
1309Queries on XOR of greatest odd divisor of the range115
1310Design Underground System Leetcode Solution114
1311Shifting Letters LeetCode Solution112
1312Detect Capital Leetcode Solution111
1313Print Maximum Length Chain of Pairs111
1314Minimum Swaps to Group All 1’s Together Leetcode Solution110
1315Top K Frequent Elements LeetCode Solution109
1316Count Sub Islands LeetCode Solution108
1317Minimum Path Sum Leetcode Solution107
1318Monotonic Array Leetcode Solution105
1319Odd Even Linked List Leetcode Solution104
1320Substring with Concatenation of All Words Leetcode Solution104
1321Longest Common Subsequence LeetCode Solution102
1322Binary Tree Inorder Traversal LeetCode Solution101
1323Decode String Leetcode Solution101
1324Find the Town Judge LeetCode Solution100
1325Maximum Population Year LeetCode Solution100
1326Shortest Unsorted Continuous Subarray LeetCode Solution95
1327Rectangle Overlap LeetCode Solution94
1328Best Meeting Point LeetCode Solution94
1329Maximum Population Year LeetCode Solution93
1330Find the Town Judge LeetCode Solution92
1331Sum Root to Leaf Numbers LeetCode Solution91
1332Insert into a Sorted Circular Linked List LeetCode Solution91
1333Flatten Binary Tree to Linked List LeetCode Solution90
1334Design Add and Search Words Data Structure LeetCode Solution89
1335Stone Game IV LeetCode Solution88
1336Reveal Cards In Increasing Order Leetcode Solution87
1337Is Graph Bipartite? LeetCode Solution87
1338Range Sum Query 2D – Immutable LeetCode Solution87
1339Valid Triangle Number LeetCode Solution86
1340Score of Parenthesis LeetCode Solution85
1341Divide Chocolate LeetCode Solution81
1342Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution75
1343Range Sum of BST LeetCode Solution69
1344Reverse Integer Leetcode Solution66
1345Rotate String LeetCode Solution64
1346Find K Closest Elements LeetCode Solution64
1347Sort Colors LeetCode Solution63
1348Maximum Side Length of a Square with Sum Less than or Equal to Threshold LeetCode Solution61
1349Excel Sheet Column Number LeetCode Solution57
1350Maximum Size Subarray Sum Equals k Leetcode Solution50
1351H-Index Leetcode Solution45
1352Camelcase Matching Leetcode Solution45
1353Valid Anagram Leetcode Solution44
1354Most Stones Removed with Same Row or Column LeetCode Solution43
1355Container With Most Water LeetCode Solution43
1356Group Anagrams LeetCode Solution42
1357Sliding Window Maximum LeetCode Solution42
1358High Five LeetCode Solution41
1359Next Permutation LeetCode Solution41
1360Find Peak Element LeetCode Solution40
1361Binary Search LeetCode Solution40
1362Pairs of Songs With Total Durations Divisible by 60 LeetCode Solution39
1363Paint House LeetCode Solution37
1364Minimum Number of Arrows to Burst Balloons LeetCode Solution36
1365Valid Triangle Number LeetCode Solution36
1366Next Greater Element I Leetcode Solution35
1367Flatten Binary Tree to Linked List LeetCode Solution35
1368Unique Binary Search Trees LeetCode Solution35
1369Isomorphic Strings LeetCode Solution35
1370Group Shifted Strings Leetcode Solution34
1371Sentence Screen Fitting LeetCode Solution33
1372The Number of Weak Characters in the Game LeetCode Solution32
1373Insert Delete GetRandom O(1) – Duplicates allowed LeetCode Solution32
1374Count Good Nodes in Binary Tree LeetCode Solution32
1375Swim in Rising Water LeetCode Solution32
1376Peak Index in a Mountain Array LeetCode Solution31
1377Closest Binary Search Tree Value II LeetCode Solution31
1378Split Linked List in Parts Leetcode Solution27
1379All Possible Full Binary Trees LeetCode Solution27
1380Validate Stack Sequences LeetCode Solution26
1381Single Element in a Sorted Array LeetCode Solution26
1382Max Sum of Two Non-Overlapping Subarrays LeetCode Solution25
1383Lowest Common Ancestor of a Binary Search Tree Leetcode Solution25
1384Best Time to Buy and Sell Stock IV LeetCode Solution24
1385Find First and Last Position of Element in Sorted Array LeetCode Solution24
1386Greatest Sum Divisible by Three LeetCode Solution24
1387Minimum Increment to Make Array Unique Leetcode Solution24
1388Trapping Rain Water II LeetCode Solution23
1389Implement strStr() LeetCode Solution23
1390Implement Rand10() Using Rand7() Leetcode Solution22
1391Stone Game IV LeetCode Solution22
1392Break a Palindrome LeetCode Solution22
1393Fibonacci Number LeetCode Solution20
1394Detect Squares LeetCode Solution20
1395Contains Duplicate LeetCode Solution20
1396Remove All Ones With Row and Column Flips Leetcode Solution19
1397Invert Binary Tree LeetCode Solution19
1398Design Bounded Blocking Queue LeetCode Solution18
1399Reverse Nodes in k-Group LeetCode Solution17
1400Minimum Number of Operations to Move All Balls to Each Box LeetCode Solution16
1401Total Hamming Distance LeetCode Solution14
1402Candy LeetCode Solution13
1403Unique Paths III LeetCode Solution11
Translate »