Divide Chocolate LeetCode Solution

Difficulty Level Hard
Frequently asked in Amazon Facebook Google
Array Binary SearchViews 47

Problem Statement

The Divide Chocolate LeetCode solution says the chocolate bar is represented by a list of non-zero integers.

The sum of a contiguous subarray stands for the sweetness of the chocolate piece represented by this subarray.

Here the task is to find the maximum possible minimum sum of all subarrays after dividing the array into k + 1 contiguous subarrays.

Example 1:


 sweetness = [1,2,3,4,5,6,7,8,9], k = 5


Explanation: You can divide the chocolate to [1,2,3], [4,5], [6], [7], [8], [9]

Example 2:


 sweetness = [5,6,7,8,9,1,2,3,4], k = 8


Explanation: There is only one way to cut the bar into 9 pieces.

Example 3:


 sweetness = [1,2,2,1,2,2,1,2,2], k = 2


Explanation: You can divide the chocolate to [1,2,2], [1,2,2], [1,2,2]




  1. This problem can be solved by the binary search method.
  2. Our search space will be from 1 to total_sweetness_value/(k+1) or we make our right-hand limit to 1e9 as it never harms our answer.
  3. Check if we can cut the chocolate into k + 1 pieces with sweetness no less than, where mid is our current guess at the optimal workable value.
  4. Now we have to take a decision according to our estimated value in the check function, if our cnt score is greater than equals (k+1) we can increase l=mid+1, else r=mid-1.


Divide Chocolate C++ Solution

class Solution {
    #define ll long long
    ll check(ll mid,ll k)
        ll i,n=a.size();
        ll sum=0,cnt=0;
        return cnt>=(k+1);
    int maximizeSweetness(vector<int>& sweetness, int k) {

        ll l=1,r=1e9,mid,ans;
        return ans;

Divide Chocolate Java Solution

class Solution {
    int a[];
    int check(int mid,int k)
        int i,n=a.length;
        int sum=0,cnt=0;
            return 1;
        return 0;
    public int maximizeSweetness(int[] sweetness, int k) {
        long l=1,mid,ans=0;
        long r = (long) Math.pow(10, 9);

        return (int)ans;

Complexity Analysis of Divide Chocolate LeetCode Solution

Time Complexity

Time Complexity is O(NlogS). N is the size of the array. S is the total sweetness.

Space Complexity

As we can see no extra space is used. So it will be O(1).

Top Interview Questions

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