Remove All Ones With Row and Column Flips Leetcode Solution

Difficulty Level Medium
Frequently asked in Google
Array Math MatrixViews 23

Problem Statement:

Remove All Ones With Row and Column Flips Leetcode Solution – You are given an m x n binary matrix grid.

In one operation, you can choose any row or column and flip each value in that row or column (i.e., changing all 0‘s to 1‘s, and all 1‘s to 0‘s).

Return true if it is possible to remove all 1‘s from grid using any number of operations or false otherwise.


Example 1:

Input : 
grid = [[0,1,0],[1,0,1],[0,1,0]]
Output: true


Remove All Ones With Row and Column Flips Leetcode SolutionPin

One possible way to remove all 1’s from the grid is to:
– Flip the middle row
– Flip the middle column

Example 2:

grid = [[1,1,0],[0,0,0],[0,0,0]]
Output: false


It is impossible to remove all 1’s from the grid.



  1. First, traverse the columns of the given grid and check if the element of the first row of that column equals 1 or not, if it is 1 then flip the value of grid[j][i], which means if the value of grid[j][i] is 0 then make it 1 and if it is 1 then make it 0.
  2. After that, we start to traverse from the second row and initialize a sum variable to 0 and then traverse all the columns and add the value of the grid to the sum variable.
  3. After coming from the inner loop we check if the sum equals 0 or equals the number of columns then we return false.
  4. Finally, if we didn’t return a false in the loop and successfully come out of the outer loop, then we return true.


C++ Program of Remove All Ones With Row and Column Flips :

class Solution {
    bool removeOnes(vector<vector<int>>& grid) {
        int n = grid.size();
        int m = grid[0].size();
        for(int i=0; i<m; i++){
            if(grid[0][i] == 1){
                for(int j=0; j<n; j++){
                    grid[j][i] = 1-grid[j][i];
        for(int i=1; i<n; i++){
            int sum = 0;
            for(int j=0; j<m; j++){
                sum += grid[i][j];
            if(sum != 0 && sum != m){
                return false;
        return true;


Java Program for  Remove All Ones With Row and Column Flips :

class Solution {
    public boolean removeOnes(int[][] grid) {
        int n = grid.length;
        int m = grid[0].length;
        for(int i=0; i<m; i++){
            if(grid[0][i] == 1){
                for(int j=0; j<n; j++){
                    grid[j][i] = 1-grid[j][i];
        for(int i=1; i<n; i++){
            int sum = 0;
            for(int j=0; j<m; j++){
                sum += grid[i][j];
            if(sum != 0 && sum != m){
                return false;
        return true;


Complexity Analysis for Remove All Ones With Row and Column Flips Leetcode Solution:

Time Complexity:

The Time Complexity of the code is O(N*M ) as we need to traverse through the given grid.

Space Complexity:

The Space Complexity of the code is O(1) because we don’t need any extra space to solve this problem.


Matrix Interview Practice Questions:

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 Tree2542
3Reverse a string without affecting special characters2526
4Palindrome using Recursion2492
5Delete a node of a linked list at given position2022
6Quick Sort1769
7Insert nodes in a linked list in a sorted way (Ascending Order)1710
8Find elements pair from array whose sum equal to number1690
9Sort Elements by Frequency of Occurrences1672
10Write a program to print all permutations of a given string1656
11Find Minimum Distance Between Two Numbers in an Array1518
12Create a Doubly Linked List1484
13Reverse an Array1465
14Smallest window in a string containing all characters of another string1440
15Recursively remove all adjacent duplicates1409
16Find a Triplet That Sum to a Given Value1392
17First Repeating Element1387
18Sum of numbers in String1364
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 Consecutive1292
22Detect a loop in the Linked List1272
23Largest Sum Contiguous Subarray1263
24Quick Sort on SIngly Linked List1258
25Recursive function to do substring search1248
26Print all Possible Combinations of R Elements in a given Array of size N1247
27Subarray with Given Sum1247
28Find the Maximum Repeating Number in Array1205
29Find the First and Second Smallest Elements1155
30Binary Tree Level order traversal in Java1155
31Check if two linked lists are identical1143
32Maximum Subarray Sum using Divide and Conquer1141
33Remove characters from first string which are in second1115
34Find Leaders in an Array1094
35Swap nodes in the linked list1085
36Find the second most frequent character1036
37Find the Number Occurring Odd Number of Times in an Array1035
38Arrange given Numbers to Form the Biggest Number II1027
39Given a string find its first non-repeating character1016
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 x995
42A Program to check if strings are rotations of each other or not992
43Total number of occurrences of a given item in the linked list991
44Print all possible words from phone digits974
45Find the Missing Number965
46Rearrange Positive and Negative Numbers Alternatively in Array953
47Longest Palindromic Substring946
48Segregate even and odd nodes in a linked list936
49Print Longest common subsequence926
50Transform one string to another using minimum number of given operations915
51Union and Intersection of Two Linked Lists905
52Check rearranged string can form a palindrome897
53Rearrange given Array in Maximum Minimum Form879
54Iterative Implementation of Quick Sort868
55Insertion Sort858
56Count Possible Triangles856
57Multiplication of Two Matrices841
58Count of Triplets With Sum Less than Given Value830
59Rotate a Linked List828
60Check if the linked list is palindrome827
61Stock Buy Sell to Maximize Profit827
62Concatenation of two strings807
63Print all duplicates in the input string798
64Tug of War798
65Count Number of Substrings with K Distinct Character’s795
66Find Nearest Greater and Smaller Element782
67Reverse String Without Temporary Variable778
68The Celebrity Problem771
69Remove ‘b’ and ‘ac’ from a given string771
70Find Pythagorean Triplets from Array769
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’s739
74Remove Minimum Characters so that Two Strings Become Anagrams738
75Find the subarray whose sum is equal to a given number X737
76Find the Peak Element from an Array735
77Addition of Two Matrices730
78Find Smallest Missing Number in a Sorted Array726
79Generate all Binary Strings Without Consecutive 1’s726
80A Product Array Puzzle723
81Maximum Sum of Non Consecutive Elements710
82Implement Two Stacks in an Array707
83Lexicographic rank of string701
84Check if Two given Matrices are Identical692
85Maximum Product Subarray II687
86Multiplication of Previous and Next681
87Subtraction of Two Matrices674
88Merge K Sorted Arrays and Print Sorted Output668
89Divide a string in N equal parts667
90Move All the Zeros to the End of the Given Array666
91Form Minimum Number from Given Sequence of D’s and I’s665
92Online Algorithm for Checking Palindrome in a Stream665
93Check whether two strings are anagram of each other657
94Remove recurring digits in a given number657
95Sort a stack using a temporary stack652
96Maximum Circular Subarray Sum649
97Sort a linked list that is sorted alternating ascending and descending645
98Subarray and Subsequence640
99Find the Minimum Element in a Sorted and Rotated Array637
100Move last element of the Linked List at first place634
101First Circular Tour to Visit all the Petrol Bunks633
102Compare two strings(linked lists)629
1033Sum Leetcode Solution628
104Largest Subarray with Equal Number of 0’s and 1’s627
105Maximum Element in an Array which is Increasing and then Decreasing627
106Palindrome Permutations of a String627
107Flattening a linked list623
108Palindromes in a given range623
109Minimum insertions to form a shortest palindrome619
110Pangram Checking619
111Majority Element618
112Run length encoding616
113Print all permutations with repetition616
114Elements Appear more than N/K times in Array611
115Minimum Characters to be Added at Front to Make String Palindrome609
116Most repeating character in a string606
117Rotate string to get lexicographically minimum string603
118Two Sum Leetcode Solution603
119Repeated Subsequence of Length Two or More601
120Merge a linked list into another at alternate positions596
121Remove all duplicates in a sorted linked list595
122Rearrange a given linked list in-place594
123Minimum number of Merge Operations to make an Array Palindrome593
124Print all anagrams together in a sequence of words592
125Reorder an Array According to the Given Indexes581
126Pancake Sorting Problem579
127Merge Overlapping Intervals II568
128Longest Palindrome can be Formed by Removing or Rearranging Characters567
129Smallest Palindrome after Replacement567
130Remove duplicates from a string566
131Transpose of a Matrix566
132Clone a Linked List with next and random pointer566
133Remove Extra Spaces from a String565
134Removing Spaces from a String using stringstream561
135Maximum Sum Increasing Subsequence560
136Check if a given string is a rotation of a palindrome560
137Size of The Subarray With Maximum Sum558
138Partition Problem552
139Check whether Strings are K Distance Apart or Not548
140Generate all Binary Strings from Given Pattern546
141Length of Longest valid Substring542
142Delete Last Occurrence541
143Check if Two given Strings are Isomorphic to each other538
144Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized535
145Insert Node in the Sorted Linked List533
146Program to Toggle all Characters in a String530
147Given string is interleaving of two other strings or not526
148Maximum difference between two elements such as larger element comes after smaller525
149Check length of a String is Equal to the Number Appended at its Last517
150Count Minimum Steps to Get the given Array514
151Number of Smaller Elements on Right Side512
152Check if all Rows of a Matrix are Circular Rotations of Each Other509
153Longest Common Prefix using Divide and Conquer508
154Find Pair with Given Difference506
155Merge sort better than quick sort for linked lists505
156Compare Two Version Numbers503
157Print all interleavings of given two strings499
158Find nth node of the Linked list from the end498
159Print Reverse of a string (Recursion)496
160Median of Two Sorted Arrays LeetCode Solution495
161Find a Fixed Point in a Given Array495
162Sort 0s 1s and 2s in an Array494
163Reorder Array Using Given Indexes493
164Reverse words in a given string492
165Find the Subarray of given length with Least Average485
166Split linked list using alternate nodes484
167Merge two sorted linked lists such that merged list is in reverse order484
168Print all Palindromic Partitions of a String477
169Print string of odd length in ‘X’ format473
170Find Element Using Binary Search in Sorted Array469
171Find K Length Subarray of Maximum Average466
172Swap Kth Node from beginning with Kth Node from End464
173Find Duplicates in an Array in Most Efficient Way459
174Shortest Superstring Problem458
175print all palindromic partitions455
176Check if String Follows Order of Characters by a Pattern or not452
177Maximum Length of Chain Pairs449
178Sort a String According to Another String448
179Flatten a multilevel linked list445
180Sorting a K Sorted Array440
181Program to add two binary digits435
182Recursively print all the sentences that can be formed from list of word lists431
183Find a Sorted Subsequence of size 3429
184Caesar Cipher428
185Longest Common Prefix Using Binary Search II427
186Longest Span with same Sum in two Binary Arrays II427
187Reverse a Linked List in groups426
188Find the two Numbers with Odd Occurrences in an Unsorted Array425
189Kth Non-repeating Character422
190Reverse a Singly Linked List (Iterative/Non-Recursive)421
191Check if String can Become Empty by Recursively Deleting given Substring418
192Longest Common Prefix Word by Word Matching414
193Rearrange a linked list in Zig-Zag412
194Rotate Image by 90 degrees407
195Permutations of a Given String Using STL407
196Pancake Sorting405
197Perfect Reversible String405
198Find First non-repeating character in a string402
199Merging Two Sorted Arrays402
2001`s and 2`s complement of binary number400
201List items containing all characters of a given word396
202Maximum occurring character in a string396
203Increasing Subsequence of Length three with Maximum Product395
204Find the point where a monotonically increasing function becomes positive first time393
205Sort a linked list with 0s, 1s and 2s390
206Four Elements that Sum to Given390
207Longest Common Prefix using Character by Character Matching387
208Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes387
209Palindrome string (number)384
210Count Number of Occurrences in a Sorted Array384
211Delete N nodes after M381
212Valid Parentheses LeetCode Solution380
213Minimum Characters to be Removed to Make a Binary String Alternate379
214Even Substring Count377
215Split a string376
216Recursive Implementation of atoi()374
217Sorting the array of strings373
218Convert a String that is Repetition of a Substring of Length K370
219Check if a Linked list of Strings form a Palindrome367
220Print Shortest Path to Print a String on Screen367
221Maximum Subarray Leetcode Solution364
222Nth Character in Concatenated Decimal String362
223Convert string1 to string2 in one edit361
224Print All Distinct Elements of the Array360
225Count the number of words360
226Reverse a singly linked list recursively359
227Reverse a String using Stack359
228wildcard character matching358
229Find the first Repeating Number in a Given Array358
230Matrix Chain Multiplication using Dynamic Programming358
231Lower Case To Upper Case355
232Can we reverse a linked list in less than O(n) time ?352
233Binary Tree to Doubly linked list350
234Longest Common Subsequence with Permutations347
235Sort Elements by Frequency II346
236Find the Lost Element From a Duplicated Array344
237Split Four Distinct Strings343
238Merge Two Sorted Arrays341
239Find middle of the Linked List338
240Roman to Integer Leetcode Solution336
241Count the Pairs at Same Distance as in English Alphabets336
242Toeplitz Matrix333
243Palindrome Permutation328
244N queen problem327
245Word Search Leetcode Solution326
246Next Greater Element in an Array325
247Move all negative elements to one side of array323
248First non Repeating Element318
249Find All Pairs With a Given Difference318
250Sudoku Solver318
251Searching a node in a Binary Search Tree318
252Reverse Bits316
253String(represents an integer) to value316
254Print all Possible Ways to Break a String in Bracket Form316
255Count Pairs With Given Sum316
256Find Nth Node315
257Number of Islands LeetCode Solution314
258Reverse a String313
259Types of Binary Tree312
260Change Gender of a given String312
261Repeated Substring Pattern312
262Triplet from three linked lists with given sum312
263Delete a Tree311
264Fibonacci numbers310
265Sort an array of strings309
266Reverse a linked list308
267Meeting Rooms II LeetCode Solution308
268Number of sub-strings which recursively add up to 9308
269Min Stack308
270How to Efficiently Implement k Stacks in a Single Array?308
271Delete a node under given conditions307
272Most Frequent Element in an Array306
273Longest Palindromic Substring LeetCode Solution305
274Cuckoo sequence program304
275Dijkstra Algorithm304
276Longest Common Extension302
277Binary Tree299
278Remove spaces from a string298
279House Robber Leetcode Solution297
280Max stack296
281Best Time to Buy and Sell Stock  II Leetcode Solution293
282Subset Leetcode293
283Word Search292
284KMP Algorithm290
285Shuffle a given Array290
286Find, second, frequent, character288
287Expression Evaluation288
288Remove middle points in a linked list of line segments288
289Minimize the maximum difference between the heights287
290Plus One Leetcode Solution287
291Combination Sum Leetcode Solution285
292Number Of 1 bits284
293Search Insert Position Leetcode Solution284
294Reverse words in a string284
295Sliding Window Technique282
296Pair of Positive Negative Values in an Array282
297Evaluation of Postfix Expression282
298Subarray with 0 sum279
299Min Stack Leetcode Solution279
300Set Matrix Zeroes279
301Rabin Karp Algorithm278
302Backspace String Compare277
303Valid Palindrome Leetcode Solution276
304Common elements in all rows of a given matrix274
305Sort linked which is sorted on absolute values273
306Merge Sorted Arrays Leetcode Solution272
307Clone a linked list with next and random pointer (Hashing)272
308Sqrt(x) Leetcode Solution270
309Reversing a Queue269
310Delete middle element of a stack269
311Contains Duplicate266
312Implementation of Deque using Doubly Linked List266
313String Compression266
314Contains Duplicate II Leetcode Solution265
315Count of index pairs with equal elements in an array265
316Count subarrays with equal number of 1’s and 0’s265
317Tower Of Hanoi265
318Intersection of Two Arrays II Leetcode Solution264
319Reverse individual words264
320Product of array except self264
321Find Top K (or Most Frequent) Numbers in a Stream264
322How to Delete a Linked List263
323Minimum swaps required to bring all elements less than or equal to k together263
324Combination Sum263
325Pascal Triangle Leetcode263
326Count Odd Numbers in an Interval Range Leetcode Solution263
327Page Replacement Algorithms in Operating Systems262
328Segregate even and odd numbers260
329Group Words With Same Set of Characters260
330Integer to Roman Leetcode Solution260
331Smallest Subarray with k Distinct Numbers259
332Bellman Ford Algorithm258
333Postfix to Infix Conversion258
334Second Most Repeated Word in a Sequence258
335Minimum Value to Get Positive Step by Step Sum Leetcode Solution258
336Single Number Leetcode Solution258
337Sorting array using Stacks258
338Sum of minimum and maximum elements of all subarrays of size k257
339Next Permutation257
340Sort elements by frequency257
341Find sum of non-repeating elements (distinct) elements in an array257
342Top K Frequent Words256
343Add Binary Leetcode Solution255
344Arithmetic Expression Evaluation255
345K-th Smallest Element in a Sorted Matrix255
346Count subarrays having total distinct elements same as original array254
347Minimum operation to make all elements equal in array254
348Given two unsorted arrays find all pairs whose sum is x254
349Construct Binary Tree from Given Inorder and Preorder Traversals253
350First element occurring k times in an array252
351Scramble String252
352Maximum Number of Balloons Leetcode Solution252
353Pow(x, n) Leetcode Solution251
354Convex Hull Algorithm251
355Palindrome Linked List Leetcode Solution251
356Special Number251
357Longest Common Prefix Leetcode Solution251
358Find Lucky Integer in an Array Leetcode Solution250
359Longest Substring Without Repeating Characters LeetCode Solution250
360Find duplicates in a given array when elements are not limited to a range250
361Majority Element Leetcode Solution249
362Design a stack that supports getMin() in O(1) time and O(1) extra space249
363Evaluate Division248
364Kruskal Algorithm248
365Permutations Leetcode Solution248
366Third Maximum Number Leetcode Solution246
367Running Sum of 1d Array Leetcode Solution244
368Maximum possible difference of two subsets of an array244
369Check if two arrays are equal or not244
370Spiral Matrix LeetCode Solution244
371Reversing the First K elements of a Queue244
372Fizz Buzz Leetcode243
373Prefix to Infix Conversion243
374Maximum Distance Between two Occurrences of Same Element in Array243
375Reverse a Number Using Stack243
376Number of Good Pairs Leetcode Solution243
377Maximum Subarray242
378Minimum Path Sum242
379Huffman Coding242
380Find Numbers with Even Number of Digits Leetcode Solution241
381Unique Paths241
382Smallest Element Repeated Exactly K Times241
383Maximal Square241
384Range Sum Query 2D – Immutable Leetcode Solution241
385Single Number240
386Find the Closest Palindrome number240
387Swap Nodes in Pairs Leetcode Solutions240
388Minimum Steps to reach target by a Knight240
389Find the Town Judge Leetcode Solution240
390Group Anagrams240
391Count Primes Leetcode Solutions240
392Find Number of Employees Under every Employee239
393Convert String To Int239
394Remove Minimum Number of Elements Such That no Common Element Exist in both Array239
395Find the first repeating element in an array of integers239
396Minimum Absolute Difference Leetcode Solution239
397Sorting using trivial hash function239
398Find top three repeated in array239
399Palindrome Substring Queries238
400Zigzag Conversion238
401Sort Array by Increasing Frequency Leetcode Solution238
402Cumulative Frequency of Count of Each Element in an Unsorted Array237
403Find All Numbers Disappeared in an Array Leetcode Solution237
404Implement Stack and Queue using Deque236
405Leetcode Permutations236
406Check if Array Contains Contiguous Integers With Duplicates Allowed236
407Pascal’s Triangle II Leetcode Solution236
408Power of Two Leetcode Solution235
409Merge Two Sorted Lists Leetcode Solutions235
410Expression Contains Redundant Bracket or Not235
411Print All Distinct Elements of a Given Integer Array235
412Count Substrings with equal number of 0s, 1s and 2s235
413Print all subarrays with 0 sum235
414Decode String234
415Length of the largest subarray with contiguous elements234
416Matrix Diagonal Sum Leetcode Solution234
417Letter Case Permutation234
418How to Implement Stack Using Priority Queue or Heap?234
419Bipartite Graph234
420Missing Number Leetcode Solution234
421Sort Integers by The Number of 1 Bit Leetcode Solution234
422Difference between highest and least frequencies in an array234
423Happy Number Leetcode Solution233
424Prim’s Algorithm233
425Subarray Sum Equals k233
426Fizz Buzz233
427House Robber II Leetcode Solution233
428Sort a stack using recursion233
429Maximum Depth of Binary Tree Leetcode Solution232
430LRU Cache Implementation232
431Find Median from data Stream231
432Top K Frequent Elements231
433Unique Paths Leetcode Solution231
434Count pairs from two linked lists whose sum is equal to a given value231
435Subarrays with distinct elements231
436Reverse Integer231
437Find all pairs (a, b) in an array such that a % b = k231
438Search in Rotated Sorted Array Leetcode Solution231
439Subset sum problem231
440Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution230
441Find Winner on a Tic Tac Toe Game Leetcode Solution230
442Coin Change 2 Leetcode Solution229
443Pair with given product228
444Find the Difference Leetcode Solution228
445Max Consecutive Ones Leetcode Solution228
446Find elements which are present in first array and not in second228
447Capacity To Ship Packages Within D Days Leetcode Solution228
448Monotonic Array LeetCode Solution228
449Nth Catalan Number228
450Check If N and Its Double Exist Leetcode Solution228
451Reverse a Stack Using Recursion228
452How Many Numbers Are Smaller Than the Current Number Leetcode Solution227
453Find The Duplicate Number227
454Integer to English words226
455Subarray Sum Equals K LeetCode Solution226
456Count and Say226
457Find distinct elements common to all rows of a matrix226
458Text Justification LeetCode Solution226
459Edit Distance225
460Longest subarray not having more than K distinct elements225
461Find Minimum In Rotated Sorted Array225
462Valid Parenthesis String225
463Find Index of Closing Bracket for a Given Opening Bracket in an Expression225
464Fibonacci Number LeetCode Solution225
465Trapping Rain Water Leetcode Solution225
466Sum of Subarray Ranges Leetcode Solution225
467Find four elements that sum to a given value (Hashmap)224
468Find any one of the multiple repeating elements in read only array224
469Floyd Warshall Algorithm224
470Remove Duplicates from Sorted Array Leetcode Solution224
471Subtract the Product and Sum of Digits of an Integer Leetcode Solution224
472Best Time to Buy and Sell Stock III Leetcode Solution224
473Priority Queue Using Singly Linked List224
474Reverse Vowels of a String Leetcode Solution224
475Reverse a String223
476Longest Common Prefix using Trie223
477Check if a given array contains duplicate elements within k distance from each other223
478Kth largest element in an Array Leetcode Solutions223
479Rearrange a binary string as alternate x and y occurrences223
480Target Sum223
481The K Weakest Rows in a Matrix Leetcode Solution222
482Design Parking System Leetcode Solution222
483Prefix to Postfix Conversion221
484Count number of triplets with product equal to given number221
485Delete a Node from linked list without head pointer221
486Jump Game Leetcode Solution221
487Generate a String With Characters That Have Odd Counts Leetcode Solution221
488MiniMax Algorithm221
489Shuffle the Array Leetcode Solution220
490Find missing elements of a range220
491Word Ladder LeetCode Solution220
492Find Common Characters Leetcode Solution220
493Shuffle String Leetcode Solution220
494Find subarray with given sum (Handles Negative Numbers)220
495Sorting a Queue without Extra Space220
496Intersection of Two Arrays219
497Degree of an array219
498The Stock Span Problem219
499Multiply Strings Leetcode Solution219
500Substring With Concatenation Of All Words219
501Flood Fill LeetCode219
502Top View of Binary Tree218
503Iterative Tower of Hanoi218
504Check for Balanced Parentheses in an Expression218
505Balanced Binary Tree Leetcode Solution218
506K-th Distinct Element in an Array218
507Merge Two Sorted Linked Lists218
508Shortest Palindrome218
509Best Time to Buy and Sell Stock LeetCode Solution218
510Postfix to Prefix Conversion217
511Minimum Delete Operations to make all Elements of Array Same217
513Priority Queue in C++217
514Kids With the Greatest Number of Candies Leetcode Solution217
515Iterative Inorder Traversal of a Binary Tree217
516Longest Common Prefix using Sorting217
517Implement a stack using single queue217
518Next Greater Element I Leetcode Solution217
519Excel Sheet Column Number Leetcode Solution217
520Number of Steps to Reduce a Number to Zero Leetcode Solution216
521Longest Common Subsequence216
522Container with Most Water216
523Slowest Key Leetcode Solution216
524Concatenation of Array LeetCode Solution216
525Peak Index in a Mountain Array216
526Count and Say Leetcode Solution216
527Reverse Words in a String III LeetCode Solution216
528Move Zeroes LeetCode Solution216
529Valid Sudoku216
530Minimum Knight Moves LeetCode Solution216
531Find the Duplicate Element216
532Next Greater Frequency Element215
533Minimum Moves to Equal Array Elements Leetcode Solution215
534Arrange given numbers to form the biggest number215
535Implement Stack using Queues215
536Sum of Left Leaves Leetcode Solutions215
537Max Area of Island215
538Find Sum of all unique sub-array sum for a given array214
539Hamming Distance214
540Find First and Last Position of Element in Sorted Array Leetcode Solution214
541Convert array into Zig-Zag fashion214
542Linked List Cycle II LeetCode Solution214
543Check if a queue can be sorted into another queue using a stack213
544Jewels and Stones Leetcode Solution213
545Largest Sum Contiguous Subarray213
546How to check if two given sets are disjoint?213
547Smallest Subarray With all Occurrences of a Most Frequent Element213
548Merge Overlapping Intervals213
549Kth Largest Element in a Stream Leetcode Solution213
550Change the Array into Permutation of Numbers From 1 to N213
551Largest Perimeter Triangle Leetcode Solution212
552Excel Sheet Column Title Leetcode Solution212
553Group Multiple Occurrence of Array Elements Ordered by first Occurrence212
554Is Subsequence Leetcode Solution212
555Isomorphic Strings Leetcode Solution212
556Find N Unique Integers Sum up to Zero Leetcode Solution212
557Shuffle an Array211
558Contiguous Array Leetcode211
559Zigzag Conversion LeetCode Solution211
560Gold Mine Problem211
561Convert a normal BST to Balanced BST210
562Maximum sum rectangle in a 2D matrix210
563Minimum number of subsets with distinct elements210
564N-th Tribonacci Number Leetcode Solution210
565Valid Anagrams210
566Count the number of nodes at given level in a tree using BFS210
567Minimum Cost to Hire K Workers210
568Minimum Bracket Reversals210
569Delete Node in a Linked List Leetcode Solution210
570Koko Eating Bananas Leetcode Solution210
571Last Stone Weight210
572Find if an Expression has Duplicate Parenthesis or Not209
573Integer to Roman209
574Summary Ranges Leetcode Solution209
5753Sum Closest LeetCode Solution208
576Shortest Path in a Grid with Obstacles Elimination LeetCode Solution208
577Maximum path sum in a triangle208
578Mobile Numeric Keypad Problem208
579Number of Provinces Leetcode Solution208
580Best Time to Buy and Sell Stock208
581Implementation of Deque using circular array208
582Smallest Good Base208
583Length of Last Word Leetcode Solution208
584Distribute Candies to People Leetcode Solution208
585Relative Sort Array Leetcode Solution207
586Find Words That Can Be Formed by Characters Leetcode Solution207
587Decode Ways207
588Maximum Distance in Array207
589Word Pattern206
590Non-overlapping sum of two sets206
591Trapping Rain Water LeetCode Solution206
592Build Array From Permutation Leetcode Solution206
593Frog Jump Leetcode Solution206
594Longest Increasing Subsequence206
595Rotate Image LeetCode Solution206
596First negative integer in every window of size k206
597Maximum Number of Occurrences of a Substring Leetcode Solution205
598Sort Characters By Frequency LeetCode Solution205
599Combinations Leetcode Solution205
600Minimum Operations to convert X to Y205
601Island Perimeter Leetcode Solution205
602Delete consecutive same words in a sequence205
603LRU Cache LeetCode Solution205
604Maximum difference between first and last indexes of an element in array205
60501 Matrix LeetCode Solution205
606Remove All Occurrences of a Substring LeetCode Solution205
607Iterative Method to find Height of Binary Tree204
608Remove Linked List Elements Leetcode Solution204
609Sieve of Eratosthenes204
610XOR Operation in an Array Leetcode Solution204
611Assign Cookies Leetcode Solution204
612Minimum number of distinct elements after removing m items204
613The Knapsack Problem204
614Bubble sort using two Stacks203
615Reverse a stack without using extra space in O(n)203
616Find the smallest positive integer value that cannot be represented as sum of any subset of a given array203
617Minimum insertions to form a palindrome with permutations allowed203
618Count all subsequences having product less than K203
619Isomorphic Strings202
620GCD Of Two Numbers202
621Find Largest d in Array such that a + b + c = d202
622Rotate List Leetcode Solution202
623Find minimum difference between any two elements202
624Sum of f(a[i], a[j]) over all pairs in an array of n integers201
625Tracking current Maximum Element in a Stack201
626Maximum Number of Chocolates to be Distributed Equally Among k Students201
627Convert Sorted Array to Binary Search Tree Leetcode Solution201
628Insert Interval Leetcode Solution201
629Permutation in String Leetcode Solution201
630Stone Game LeetCode201
631Find the Duplicate Number LeetCode Solution200
632Optimal Account Balancing LeetCode Solution200
633How to Create Mergable Stack?200
634Reorganize String200
635Form minimum number from given sequence200
636Defanging an IP Address Leetcode Solution200
637Same Tree LeetCode Solution200
638Unique Binary Search Trees200
639K Empty Slots200
640Applications of Breadth First Search and Depth First Search200
641Count Good Nodes in Binary Tree Leetcode Solution199
642Longest Increasing Path in a Matrix LeetCode Solution199
643Distance Between Bus Stops Leetcode Solution199
644Convert an array to reduced form199
645First Unique Character in a String LeetCode Solution198
646Minimum Depth of Binary Tree Leetcode Solution198
647License Key Formatting Leetcode Solution198
648Employee Free Time LeetCode Solution198
649Find pairs with given sum such that elements of pair are in different rows198
650Printing brackets in Matrix Chain Multiplication Problem198
651Letter Combinations of a Phone Number197
652Replace Elements with Greatest Element on Right Side Leetcode Solution197
653Painting Fence Algorithm197
654Find Pair with Greatest Product in Array197
655Word Wrap Problem197
656Longest Substring with At Most K Distinct Characters LeetCode Solution197
657Convert a Number to Hexadecimal Leetcode Solution196
658Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions196
659Check If It Is a Straight Line Leetcode Solution196
660Largest subarray with equal number of 0s and 1s196
661Robot Room Cleaner Leetcode Solution196
662Reducing Dishes LeetCode Solution196
663Sort Array By Parity LeetCode Solution196
664Merge Two Balanced Binary Search Trees196
665House Robber196
666Coin Change Problem196
667Moving Average from Data Stream Leetcode Solution195
668Longest Span with same Sum in two Binary arrays195
669Segregate 0s and 1s in an Array195
670Find the node with minimum value in a Binary Search Tree195
671Strobogrammatic Number LeetCode Solution195
672Print the Fibonacci numbers in reverse order195
673Maximum Consecutive Numbers Present in an Array195
674K Empty Slots LeetCode195
675Partition Labels LeetCode Solution194
676Queries for counts of array elements with values in given range194
677Valid Palindrome194
678Reservoir Sampling194
679Find Leaves of Binary Tree LeetCode Solution194
680Dynamic Programming Basics194
681Kth Missing Positive Number Leetcode Solution194
682String Compression LeetCode Solution194
683Flipping an Image LeetCode Solution194
684Find Maximum Level sum in Binary Tree193
685Valid Palindrome II Leetcode Solution193
686String to Integer (atoi) LeetCode Solution193
687Partition Array Into Three Parts With Equal Sum Leetcode Solution193
688Distance of nearest cell having 1 in a binary matrix193
689Sum of All Odd Length Subarrays Leetcode Solution193
690Find the Distance Value Between Two Arrays Leetcode Solution193
691k-th missing element in increasing sequence which is not present in a given sequence193
692Maximum Product of Two Elements in an Array Leetcode Solution193
693Longest Substring with At Least K Repeating Characters LeetCode Solution193
694Best Time to Buy and Sell Stock with Cooldown Leetcode Solution193
695Power of Four Leetcode Solution193
696Generate all possible sorted arrays from alternate elements of two given sorted arrays192
697Check If Two String Arrays are Equivalent Leetcode Solution192
698Reverse Only Letters LeetCode Solution192
699Numbers with prime frequencies greater than or equal to k192
700Find unique character in a string192
701Remove brackets from an algebraic string containing + and – operators191
702Count quadruples from four sorted arrays whose sum is equal to a given value x191
703Remove Invalid Parentheses Leetcode Solution191
704Maximum Number of Coins You Can Get Leetcode Solution191
705Path With Maximum Minimum Value LeetCode Solution191
706Find whether an array is subset of another array191
707To Lower Case Leetcode Solution191
708Find the Smallest Divisor given a Threshold Leetcode Solution191
709Edit Distance LeetCode Solution191
710Increasing Decreasing String Leetcode Solution191
711Binary Tree Maximum Path Sum LeetCode Solution191
712Merge Two Binary Trees LeetCode Solution190
713Number of Dice Rolls With Target Sum LeetCode Solution190
714Wiggle Sort190
715Find the largest multiple of 3190
716Inorder Successor of a node in Binary Tree190
717Delete Nth node from the end of the given linked list190
718Sort Array by Increasing Frequency Leetcode Solution190
719Unique Paths II Leetcode Solution190
720Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest190
721Permutation Sequence LeetCode Solution190
722Recover Binary Search Tree189
723Subset Sum Leetcode189
724Snakes and Ladders LeetCode Solution189
725BFS vs DFS for Binary Tree189
726Populating Next Right Pointers in Each Node189
727Stack Permutations (Check if an array is stack permutation of other)189
728Find if Path Exists in Graph Leetcode Solution189
729Non-decreasing Array LeetCode Solution189
730Bulb Switcher LeetCode Solution189
731Race Car LeetCode Solution189
732Base 7 Leetcode Solution189
733Factorial Trailing Zeroes Leetcode Solution189
734Valid Perfect Square Leetcode Solution189
735Lucky Numbers in a Matrix Leetcode Solution189
736Maximum Length of a Concatenated String with Unique Characters Leetcode Solution188
737Merge Sorted Array LeetCode Solution188
738Check for Palindrome after every character replacement Query188
739Perform String Shifts Leetcode188
740Elements to be added so that all elements of a range are present in array188
741Binary Tree zigzag level order Traversal188
742Ugly Number Leetcode Solution188
743Find Maximum Depth of Nested Parenthesis in a String188
744Tiling Problem188
745Valid Number188
746Reversing a Queue using Recursion188
747Number of NGEs to the Right188
748Minimum sum of multiplications of n numbers187
749Restore IP Addresses Leetcode Solution187
750Student Attendance Record I Leetcode Solution187
751Majority Element II Leetcode Solution187
752Best Meeting Point LeetCode Solution187
753Minimum Cost For Tickets Leetcode Solution187
754String comparison containing wildcards187
755Keyboard Row Leetcode Solution187
756Growable array based stack187
757Program for Bridge and Torch problem187
758Maximum 69 Number Leetcode Solution187
759Evaluate Reverse Polish Notation LeetCode Solution187
760Add and Search Word – Data structure design LeetCode187
761Binary Tree Zigzag Level Order Traversal LeetCode Solution187
762Check if Two Expressions With Brackets are Same186
763Print a Binary Tree in Vertical Order186
764Split a String in Balanced Strings Leetcode Solution186
765Rank Transform of an Array Leetcode Solution186
766Word Pattern LeetCode Solution186
767Construct BST from given Preorder Traversal186
768Regular Expression Matching186
769Morris Traversal186
770N-Queens LeetCode Solution186
771Maximum Profit in Job Scheduling Leetcode Solution186
772Maximum Product of Three Numbers LeetCode Solution185
773Finding K closest element185
774Binomial Coefficient185
775Hamming Distance Leetcode Solution185
776Jump Game185
777Count items common to both the lists but with different prices185
778Symmetric Tree Leetcode Solution185
779Sorted Linked List to Balanced BST185
780Find Median from Data Stream LeetCode Solution185
781Priority Queue using doubly linked list185
782Brick Wall LeetCode Solution185
783Number of Days Between Two Dates LeetCode Solution185
784Find All Possible Recipes from Given Supplies LeetCode Solution185
785Check If Array Pairs Are Divisible by k LeetCode Solution184
786Partition to K Equal Sum Subsets Leetcode Solution184
787Minimize Maximum Pair Sum in Array LeetCode Solution184
788Find All Duplicates in an Array LeetCode Solution184
789Special Array With X Elements Greater Than or Equal X Leetcode Solution184
790Longest Subarray Having Count of 1s One More than Count of 0s184
791Top K Frequent Words LeetCode Solution184
792Sort an array according to the order defined by another array183
793Linked List Cycle183
794Largest Rectangle in Histogram LeetCode Solution183
795Decompress Run-Length Encoded List Leetcode Solution183
796Minimum Distance Between BST Nodes Leetcode Solution183
797Minimum Time Visiting All Points Leetcode Solution183
798Merge K Sorted Linked Lists183
799Total Numbers With no Repeated Digits in a Range183
800Form Minimum Number From Given Sequence183
801Search in a Binary Search Tree Leetcode Solution183
802Maximum Depth of N-ary Tree Leetcode Solution183
803Remove Nth Node From End of List Leetcode Solution182
804Kth ancestor of a node in binary tree182
805Minimum Height Trees182
806Number of Islands II LeetCode Solution182
807Largest rectangular sub-matrix whose sum is 0182
808Nearest Exit from Entrance in Maze LeetCode Solution182
809One Edit Distance LeetCode Solution182
810Invert Binary Tree LeetCode Solution182
811Maximum Difference Between Increasing Elements LeetCode Solution182
812Queue based approach for first non-repeating character in a stream182
813Maximum Nesting Depth of the Parentheses Leetcode Solution182
814Nested List Weight Sum II LeetCode Solution182
815Given an Array of Pairs Find all Symmetric Pairs in it181
816Final Prices With a Special Discount in a Shop Leetcode Solution181
817Circular Queue181
818Repeated Substring Pattern LeetCode Solution181
819Identify and Mark Unmatched Parenthesis in an Expression181
820Diagonal Traversal of Binary Tree181
821Balanced Expression with Replacement181
822Last Stone Weight II LeetCode Solution180
823A Space Optimized DP solution for 0-1 Knapsack Problem180
824Minimum time required to rot all oranges180
825Transpose Graph180
826Relative Ranks Leetcode Solution180
827Lemonade Change Leetcode Solution180
828Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution179
829Course Schedule II – LeetCode179
830LCS (Longest Common Subsequence) of three strings179
831Minimum Jumps to Reach Home LeetCode Solution179
832Sliding Window Maximum179
833Minimum Swaps to Make Strings Equal Leetcode Solution179
834Search a 2D Matrix II Leetcode Solution179
835Reorder Data in Log Files LeetCode Solution179
836Check if a given array can represent Preorder Traversal of Binary Search Tree179
837Daily Temperatures Leetcode Solution179
838Clone Graph LeetCode Solution179
839Deletion in a Binary Tree179
840Subarray Product Less Than K LeetCode Solution179
841Minimum Number of Taps to Open to Water a Garden LeetCode Solution179
842Missing Element in Sorted Array LeetCode Solution179
843Permutation Coefficient179
844Crawler Log Folder Leetcode Solution179
845Tree Traversal (Preorder, Inorder & Postorder)178
846Subsequence of Size K With the Largest Even Sum LeetCode Solution178
847Split Array Into Consecutive Subsequences178
848Find Maximum Sum Possible Equal Sum of Three Stacks178
849Remove Duplicates from Sorted List II178
850Binary Search Tree Search and Insertion178
851Remove Duplicates from Sorted List LeetCode Solution178
852Insert Delete GetRandom178
853Check if an Array is Stack Sortable178
854Sort Array By Parity II Leetcode Solution178
855Find the Only Repetitive Element Between 1 to N-1178
856Distinct adjacent elements in an array178
857Find all permuted rows of a given row in a matrix178
858Number Complement Leetcode Solution178
859Design Browser History LeetCode Solution178
860Guess Number Higher or Lower LeetCode Solution177
861Get Maximum in Generated Array Leetcode Solution177
862Minimum number of jumps to reach end177
863An Interesting Method to generate Binary Numbers from 1 to n177
864Iterative Preorder Traversal177
865Check if stack elements are pairwise consecutive177
866Alien Dictionary LeetCode Solution177
867Spiral Matrix II Leetcode Solution177
868Matrix Chain Multiplication176
869Union and Intersection of two Linked Lists176
870Valid Parentheses Leetcode Solution176
871Sort Colors176
872Count Distinct Elements in Every Window of Size K176
873Minimum Sum Path in a Triangle176
874Sum of nearest smaller and greater number176
875Minimum swaps to make sequences increasing176
876Partition List Leetcode Solution176
877Find the subarray with least average176
878Interval Tree176
879Subset with sum divisible by m176
880Path with maximum average value176
881Iterative Postorder Traversal Using Two Stacks175
882Friends Pairing Problem175
883Range LCM Queries175
884Least Number of Unique Integers after K Removals Leetcode Solution175
885Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i175
886Brightest Position on Street LeetCode Solution175
887Dividing Array into Pairs With Sum Divisible by K175
888Water Bottles Leetcode Solution175
889Count ways to reach the nth stair using step 1, 2 or 3175
890Time Based Key-Value Store LeetCode Solution175
891Sequences of given length where every element is more than or equal to twice of previous175
892Convert BST to Min Heap175
893Find all triplets with zero sum175
894Design a Stack With Increment Operation Leetcode Solution175
895Sorted Array to Balanced BST175
896Diagonal Traversal LeetCode Solution175
897Can Place Flowers LeetCode Solution175
898GCDs of given index ranges in an array174
899Level order Traversal in Spiral Form174
900Number of Distinct Islands Leetcode Solution174
901Infix to Postfix174
902Diagonal Traverse LeetCode Solution174
903Check whether a given Binary Tree is Complete or not174
904Pattern Occurrences using Stack174
905Count Negative Numbers in a Sorted Matrix LeetCode Solution174
906Find distance between two nodes of a Binary Tree174
907Delete And Earn174
908Maximum size subarray sum equals k174
909Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution174
910Minesweeper LeetCode Solution174
911Range sum queries without updates173
912Set Matrix Zeroes Leetcode Solution173
913Insert into a Binary Search Tree Leetcode Solution173
914Maximum Score After Splitting a String Leetcode Solution173
915Destination City Leetcode Solution173
916Median of Two Sorted Arrays173
917Guess Number Higher or Lower II173
918All Unique Triplets that Sum up to a Given Value173
919Shortest Word Distance Leetcode Solution173
920Robot Bounded In Circle LeetCode Solution172
921Binary Tree Longest Consecutive Sequence LeetCode Solution172
922Rearrange an Array Such that arr[i] is equal to i172
923Binary array after M range toggle operations172
924Lexicographical Numbers Leetcode Solution172
925A program to check if a binary tree is BST or not172
926Check if any two intervals overlap among a given set of intervals172
927Difference Array | Range update query in O(1)171
928Rearrange Spaces Between Words Leetcode Solution171
929Construct the Rectangle Leetcode Solution171
930Convert Sorted List to Binary Search Tree171
931Product of Array Except Self LeetCode Solution171
932Three way partitioning of an array around a given range171
933Find Common Characters Leetcode Solution171
934Count Submatrices With All Ones LeetCode Solution171
935Alien Dictionary171
936Special Positions in a Binary Matrix Leetcode Solution171
937Check if the given array can represent Level Order Traversal of Binary Search Tree171
938Averages of Levels in Binary Tree171
939My Calendar I LeetCode Solution171
940Longest Palindromic Subsequence170
941Queue using Stacks170
942Construct Complete Binary Tree from its Linked List Representation170
943Analyze User Website Visit Pattern LeetCode Solution170
944Count Subarrays with Same Even and Odd Elements170
945Palindrome Partitioning Leetcode Solution170
946Trim a Binary Search Tree170
947Three Consecutive Odds Leetcode Solution170
948K’th Largest Element in BST when modification to BST is not allowed170
9493 Sum170
950Spiral Matrix III LeetCode Solution170
951Vertical sum in a given binary tree169
952Maximum Frequency Stack Leetcode Solution169
953Number of Equivalent Domino Pairs Leetcode Solution169
954Remove Duplicates from Sorted List II LeetCode Solution169
955Word Break169
956Create Maximum Number169
958Merge Two Sorted Lists Leetcode169
959Minimum Height Trees LeetCode Solution169
960Intersection of Two Linked Lists LeetCode Solution169
961Strongly Connected Component168
962Climbing stairs168
963Symmetric Tree168
964Queries for GCD of all numbers of an array except elements in a given range168
965BFS for Disconnected Graph168
966Maximize Sum of Array after K Negations Leetcode Solution168
967Largest area rectangular sub-matrix with equal number of 1’s and 0’s168
968Maximum Product Subarray167
969Asteroid Collision LeetCode Solution167
970Unique Paths II167
971Print Fibonacci sequence using 2 variables167
972Kth Smallest Element in a BST Leetcode Solution167
973Count subarrays where second highest lie before highest167
974Depth First Search (DFS) for a Graph167
975Merging Intervals167
976Longest subsequence such that difference between adjacents is one167
977Construct BST from its given Level Order Traversal167
978Sign of the Product of an Array LeetCode Solution167
979Reverse Nodes in K-Group167
980Count Primes in Ranges167
981Stone Game II Leetcode166
982Count pair with Given Sum166
983Maximum Subarray Sum Excluding Certain Elements166
984Number of palindromic paths in a matrix166
985Breadth First Search (BFS) for a Graph166
986Serialize and Deserialize Binary Tree166
987Combination Sum IV LeetCode Solution166
988Design Hit Counter LeetCode Solution166
989Longest Nice Substring LeetCode Solution166
990Scramble String LeetCode Solution165
991Maximum Length of Repeated Subarray165
992Can Make Arithmetic Progression From Sequence Leetcode Solution165
993Find the First Circular Tour that visits all the Petrol Pumps165
994The Maze III LeetCode Solution165
995Largest Number Leetcode Solution165
996K maximum sums of overlapping contiguous sub-arrays165
997Find number of pairs in an array such that their XOR is 0165
998K Closest Points to Origin Leetcode Solution165
999Next Permutation Leetcode Solution165
1000Valid Boomerang Leetcode Solution165
1001Find Maximum of Minimum for Every Window Size in a Given Array165
1002String Matching in an Array Leetcode Solution165
1003Binary Search Tree Delete Operation165
1004Print Next Greater Number of Q queries164
1005Remove Duplicates from Sorted Array II Leetcode Solution164
1006Kth Smallest Element in a Sorted Matrix LeetCode Solution164
1007Height of a generic tree from parent array164
1008Maximum length subsequence with difference between adjacent elements as either 0 or 1164
1009Maximum difference between frequency of two elements such that element having greater frequency is also greater164
1010Find the Difference Leetcode Solution164
1011Palindrome Partitioning164
1012Shuffle 2n integers as without using extra space164
1013Largest Substring Between Two Equal Characters Leetcode Solution164
1014Count pairs from two sorted arrays whose sum is equal to a given value x164
1015Newman-Conway Sequence164
1016Collect maximum points in a grid using two traversals164
1017Maximum Product of Indexes of Next Greater on Left and Right164
1018The Painter’s Partition Problem163
1019Segment Tree163
1020Graph Valid Tree LeetCode Solution163
1021Consecutive Characters LeetCode Solution163
1022Shortest Completing Word Leetcode Solution163
1023Friends Of Appropriate Ages LeetCode Solution163
1024Find postorder traversal of BST from preorder traversal163
1025Minimum Index Sum of Two Lists163
1026Balanced Binary Tree163
1027Length of Longest Fibonacci Subsequence163
1028Level Order Traversal of Binary Tree163
1029Generate Parentheses Leetcode Solution163
1030Maximum Number of Ways to Partition an Array LeetCode Solution162
1031Merge Sort162
1032Largest divisible pairs subset162
1033Validate Binary Search Tree162
1034Rearrange array such that even positioned are greater than odd162
1035Find Duplicate Subtrees162
1036Move all negative elements to end in order with extra space allowed162
1037Boolean Parenthesization Problem162
1038Boundary Traversal of binary tree162
1039Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution162
1040Invalid Transactions LeetCode Solution162
1041Path Sum II LeetCode Solution162
1042Maximum Sum of 3 Non-Overlapping Subarrays162
1043Decrypt String from Alphabet to Integer Mapping Leetcode Solution162
1044Find a Peak Element II LeetCode Solution161
1045Available Captures for Rook Leetcode Solution161
1046Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’161
1047Custom Sort String Leetcode Solution161
1048Next Greater Element III LeetCode Solution161
1049Construction of Longest Increasing Subsequence (N log N)161
1050Number Of Longest Increasing Subsequence161
1051Build an Array With Stack Operations Leetcode Solution161
1052First missing positive161
1053Make The String Great Leetcode Solution161
1054Advantages of BST over Hash Table160
1055Bitwise AND of Numbers Range LeetCode Solution160
1056Compute nCr % p160
1057Binary Search Tree160
1058Kill Process LeetCode Solution160
1059Iterative Depth First Traversal of Graph160
1060Insertion in a Binary Tree160
1061Construct Binary Tree from given Parent Array representation160
1062Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution159
1063Double the first element and move zero to end159
1064Add two numbers159
1065Rearrange array such that even index elements are smaller and odd index elements are greater159
1066Recover Binary Search Tree Leetcode Solution159
1067Ugly Numbers159
1068Minimum Size Subarray Sum159
1069Print Right View of a Binary Tree159
1070Subarrays with K Different Integers Leetcode Solution159
1071Count minimum steps to get the given desired array159
1072Morris Inorder Traversal158
1073Remove Palindromic Subsequences Leetcode Solution158
1074Regular Expression Matching Regular Expression Matching LeetCode Solution158
1075Employee Importance LeetCode Solution158
1076Find Peak Element158
1077Partition Equal Subset Sum158
1078Largest BST Subtree LeetCode Solution158
1079Maximum subsequence sum such that no three are consecutive158
1080Defanging an IP Address LeetCode Solution158
1081Smallest Common Region Leetcode Solution157
1082Level order traversal using two Queues157
1083Maximum weight transformation of a given string157
1084Find maximum difference between nearest left and right smaller elements157
1085Implement Trie (Prefix Tree) Leetcode Solution156
1086Cells with Odd Values in a Matrix LeetCode Solution156
1087Longest Bitonic Subsequence156
1088Number of siblings of a given Node in n-ary Tree156
1089Palindrome Permutation LeetCode Solution156
1090Binary Tree Right Side View LeetCode Solution156
1091Remove duplicates from sorted array156
1092Lowest Common Ancestor156
1093Ugly Number II LeetCode Solution156
1094Super Ugly Number156
1095Find whether a subarray is in form of a mountain or not156
1096Path Sum155
1097Populating Next Right Pointers in Each Node Leetcode Solution155
1098Valid Tic-Tac-Toe State LeetCode Solution155
1099Maximize Distance to Closest Person LeetCode Solution155
1100Palindromic Substrings Leetcode Solution155
1101Number of Closed Islands Leetcode Solution155
1102Kth Smallest Product of Two Sorted Arrays LeetCode Solution155
1103Bus Routes Leetcode Solution155
1104Search in Sorted Rotated Array155
1105Increasing Triplet Subsequence LeetCode Solution155
1106Print all triplets in sorted array that form AP155
1107Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution155
1108Sum of Even Numbers After Queries154
1109Clone a Binary Tree with Random Pointers154
1110Iterative method to find ancestors of a given binary tree154
1111Divisible Pairs Counting154
1112Serialize and Deserialize Binary Tree LeetCode Solution154
1113Find Three Element From Different Three Arrays Such That a + b + c = sum154
1114Products of ranges in an array154
1115Find the minimum distance between two numbers154
1116Reformat The String Leetcode Solution154
1117Binary Tree Data Structure153
1118Number of Students Doing Homework at a Given Time Leetcode Solution153
1119Moser-de Bruijn Sequence153
1120Distinct Subsequences153
1121Day of the Year Leetcode Solution153
1122Thousand Separator Leetcode Solution153
1123Bottom View of a Binary Tree152
1124Level of Each node in a Tree from source node152
1125Search Insert Position152
1126Find Smallest Range Containing Elements from k Lists152
1127Longest Subarray of 1’s After Deleting One Element LeetCode Solution152
1128Reformat Date LeetCode Solution152
1129Root to Leaf path with target sum Leetcode Solutions152
1130Mean of Array After Removing Some Elements Leetcode Solution152
1131Minimum Absolute Difference in BST Leetcode Solution152
1132Count Largest Group Leetcode Solution152
1133Third Maximum Number Leetcode Solution151
1134Longest Increasing Consecutive Subsequence151
1135Write Code to Determine if Two Trees are Identical151
1136Longest Repeated Subsequence151
1137Maximum Product Subarray151
1138Queries for Number of Distinct Elements in a Subarray151
1139Print modified array after executing the commands of addition and subtraction150
1140Diameter of N-Ary Tree LeetCode Solution150
1141Construct K Palindrome Strings LeetCode Solution150
1142Maximum Product of Splitted Binary Tree LeetCode Solution150
1143Convert BST into a Min-Heap without using array150
1144Minimum Moves to Equal Array Elements LeetCode Solution150
1145Prime Palindrome LeetCode Solution150
1146Closest Leaf in a Binary Tree LeetCode Solution150
1147Topological Sorting150
1148Minimum sum of squares of character counts in a given string after removing k characters150
1149Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution150
1150Golomb sequence150
1151Maximum Depth Of Binary Tree150
1152Constant time range add operation on an array150
1153Compare Strings by Frequency of the Smallest Character Leetcode Solution150
1154Find maximum length Snake sequence150
1155Rotate Array149
1156Kth Smallest Number in Multiplication Table Leetcode Solution149
1157Minimum Score Triangulation of Polygon Leetcode Solution149
1158Contiguous Array LeetCode Solution149
1159Search Suggestions System LeetCode Solution149
1160Search an Element in Sorted Rotated Array149
1161Swap Nodes In Pairs149
1162Subset Sum Problem in O(sum) space149
1163Priority Queue149
1164Web Crawler LeetCode Solution148
1165Count even length binary sequences with same sum of first and second half bits148
1166Cutting a Rod148
1167Find Largest Value in Each Tree Row LeetCode Solution148
1168Factorial Trailing Zeroes LeetCode Solution147
1169Reverse a Path in BST using Queue147
1170Decision Tree147
1171Possible Bipartition LeetCode Solution147
1172Closest Binary Search Tree Value Leetcode Solution147
1173Find a sorted subsequence of size 3 in linear time147
1174Delete Nodes and Return Forest Leetcode Solution147
1175Maximize sum of consecutive differences in a circular array147
1176Check Array Formation Through Concatenation Leetcode Solution147
1177Perfect Squares LeetCode Solution147
1178Count Pairs Whose Products Exist in Array146
1179Replace two consecutive equal values with one greater146
1180Matchsticks to Square Leetcode Solution146
1181Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution146
1182Red-Black Tree Introduction146
1183Minimum Sideway Jumps LeetCode Solution146
1184Binary Tree to Binary Search Tree Conversion146
1185Minimum Swaps To Make Sequences Increasing LeetCode Solution146
1186Given a binary tree, how do you remove all the half nodes?146
1187Transform a BST to Greater sum Tree146
1188Maximum Binary Tree146
1189Minimum Cost to Move Chips to The Same Position LeetCode Solution146
1190Concatenation of Array LeetCode Solution146
1191Decrease Elements To Make Array Zigzag LeetCode Solution145
1192Maximum sum of a path in a Right Number Triangle145
1193Sum of Left Leaves LeetCode Solution145
1194Valid Triangle Number145
1195K’th Largest element in BST using constant extra space145
1196Maximum number of segments of lengths a, b and c144
1197First Bad Version144
1198Merge two BSTs with limited extra space144
1199Maximum sum bitonic subarray144
1200Maximum Value at a Given Index in a Bounded Array LeetCode Solution144
1201Find the smallest binary digit multiple of given number144
1202Divide Two Integers Leetcode Solution144
1203Queries on Probability of Even or Odd Number in given Ranges144
1204Path Crossing Leetcode Solution144
1205Number of Orders in the Backlog Leetcode Solution144
1206Valid Perfect Square LeetCode Solution143
1207Swapping Nodes in a Linked List Leetcode Solution143
1208Maximum sum of pairs with specific difference143
1209Queue Reconstruction by Height143
1210Sliding Window Median Leetcode Solution143
1211Print n terms of Newman-Conway Sequence143
1212Lowest Common Ancestor of a Binary Tree Leetcode Solution143
1213Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution143
1214Convert Sorted Array to Binary Search Tree LeetCode Solutions142
1215Find minimum number of merge operations to make an array palindrome142
1216Integer Break LeetCode Solution142
1217Guess The Word142
1218How to print maximum number of A’s using given four keys142
1219Array Queries for multiply replacements and product141
1220Graph and its representation141
1221Moving Stones Until Consecutive Leetcode Solution141
1222New 21 Game141
1223Range Sum Query using Sparse Table141
1224Check if all levels of two Binary Tree are anagrams or not140
1225Lowest Common Ancestor in Binary Search Tree140
1226Champagne Tower LeetCode Solution140
1227Flatten 2D Vector LeetCode Solution140
1228Find Minimum in Rotated Sorted Array II LeetCode Solution140
1229Kth Smallest Element in a BST140
1230Merge k Sorted Lists Leetcode Solution139
1231Maximum Array from Two given Arrays Keeping Order Same139
1232LRU Cache Leetcode Solution139
1233Longest Common Prefix Using Word by Word Matching139
1234Range Queries for Longest Correct Bracket Subsequence139
1235Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution139
1236Write a function to get the intersection point of two Linked Lists138
1237Largest Plus Sign Leetcode Solution138
1238Maximum Product Subarray138
1239Bold Words in String LeetCode Solution138
1240Maximum Sum Increasing Subsequence138
1241BST to a Tree with Sum of all Smaller Keys138
1242Maximize Elements Using Another Array138
1243The kth Factor of n Leetcode Solution138
1244Contiguous Array138
1245Mean of range in array138
1246Design Skiplist LeetCode Solution138
1247Missing Number138
1248Print modified array after multiple array range increment operations137
1249Count Subsets Having Distinct Even Numbers137
1250Minimum Remove to Make Valid Parentheses LeetCode Solution137
1251Find k-th smallest element in BST (Order Statistics in BST)137
1252Parallel Courses II LeetCode Solution136
1253Arithmetic Slices II – Subsequence LeetCode Solution136
1254Min Cost Climbing Stairs LeetCode Solution136
1255Graph Cloning135
1256Image Overlap LeetCode Solution135
1257Different Ways to Add Parentheses Leetcode Solution135
1258Check in binary array the number represented by a subarray is odd or even135
1259Power of Two135
1260Check if each internal node of a BST has exactly one child135
1261Koko Eating Bananas LeetCode Solution134
1262Check for Identical BSTs without building the trees134
1263Minimum Time to Collect All Apples in a Tree LeetCode Solution134
1264Verify Preorder Serialization of a Binary Tree134
1265Check Completeness of a Binary Tree LeetCode Solution134
1266Print Ancestors of a Given Binary Tree Node Without Recursion133
1267Symmetric Tree LeetCode Solution Leetcode Solution133
1268Check if two nodes are on the same path in a Tree133
1269Smallest Range II Leetcode Solution133
1270Longest Substring Without Repeating Characters Leetcode Solution132
1271Orderly Queue LeetCode Solution132
1272Next greater element132
1273Excel Sheet Column Title LeetCode Solution131
1274Count and Toggle Queries on a Binary Array131
1275Merge Sorted Array131
1276Arranging Coins Leetcode Solution130
1277Vertical Order Traversal of Binary Tree LeetCode Solution130
1278Largest Submatrix With Rearrangements LeetCode Solution129
1279Palindrome Number LeetCode Solution129
1280Array Nesting Leetcode Solution129
1281Palindrome Partitioning129
1282Number of elements less than or equal to a given number in a given subarray129
1283Check if X can give change to every person in the Queue127
1284Peeking Iterator LeetCode Solution127
1285Find the Winner of the Circular Game LeetCode Solution126
1286Add Two Numbers II Leetcode Solution126
1287Newman–Shanks–Williams prime126
1288Check If a String Can Break Another String Leetcode Solution126
1289Maximum product of an increasing subsequence126
1290Queries for Decimal Values of Subarrays of a Binary Array125
1291Insert Delete GetRandom O(1) Leetcode Solution125
1292Find maximum average subarray of k length125
1293Continuous Subarray Sum LeetCode Solution125
1294Range Minimum Query (Square Root Decomposition and Sparse Table)125
1295Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution124
1296Check given array of size n can represent BST of n levels or not123
1297Encoded String With Shortest Length LeetCode Solution123
1298Jump Game IV LeetCode Solution122
1299Reach a Number LeetCode Solution121
1300Minimum Number of People to Teach LeetCode Solution121
1301Random Pick Index LeetCode Solution121
1302Binary Tree to Binary Search Tree Conversion using STL set121
1303Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution121
1304Convert to Base -2 LeetCode Solution121
1305Number of indexes with equal elements in given range120
1306Convert a BST to a Binary Tree such that sum of all greater keys is added to every key119
1307Minimum Total Space Wasted With K Resizing Operations LeetCode Solution118
1308Design A Leaderboard Leetcode Solution116
1309Design Underground System Leetcode Solution116
1310Shifting Letters LeetCode Solution115
1311Queries on XOR of greatest odd divisor of the range115
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 Solution110
1316Count Sub Islands LeetCode Solution108
1317Substring with Concatenation of All Words Leetcode Solution108
1318Minimum Path Sum Leetcode Solution108
1319Odd Even Linked List Leetcode Solution107
1320Monotonic Array Leetcode Solution106
1321Binary Tree Inorder Traversal LeetCode Solution104
1322Decode String Leetcode Solution103
1323Longest Common Subsequence LeetCode Solution103
1324Maximum Population Year LeetCode Solution103
1325Find the Town Judge LeetCode Solution102
1326Shortest Unsorted Continuous Subarray LeetCode Solution98
1327Best Meeting Point LeetCode Solution96
1328Rectangle Overlap LeetCode Solution96
1329Sum Root to Leaf Numbers LeetCode Solution93
1330Maximum Population Year LeetCode Solution93
1331Find the Town Judge LeetCode Solution92
1332Insert into a Sorted Circular Linked List LeetCode Solution92
1333Design Add and Search Words Data Structure LeetCode Solution92
1334Flatten Binary Tree to Linked List LeetCode Solution92
1335Stone Game IV LeetCode Solution90
1336Is Graph Bipartite? LeetCode Solution88
1337Valid Triangle Number LeetCode Solution88
1338Range Sum Query 2D – Immutable LeetCode Solution88
1339Reveal Cards In Increasing Order Leetcode Solution88
1340Score of Parenthesis LeetCode Solution87
1341Divide Chocolate LeetCode Solution82
1342Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution76
1343Range Sum of BST LeetCode Solution71
1344Reverse Integer Leetcode Solution69
1345Rotate String LeetCode Solution66
1346Find K Closest Elements LeetCode Solution66
1347Sort Colors LeetCode Solution65
1348Maximum Side Length of a Square with Sum Less than or Equal to Threshold LeetCode Solution62
1349Excel Sheet Column Number LeetCode Solution60
1350Maximum Size Subarray Sum Equals k Leetcode Solution51
1351H-Index Leetcode Solution47
1352Camelcase Matching Leetcode Solution45
1353Valid Anagram Leetcode Solution45
1354Most Stones Removed with Same Row or Column LeetCode Solution44
1355Container With Most Water LeetCode Solution43
1356Sliding Window Maximum LeetCode Solution43
1357High Five LeetCode Solution43
1358Group Anagrams LeetCode Solution42
1359Next Permutation LeetCode Solution41
1360Find Peak Element LeetCode Solution41
1361Binary Search LeetCode Solution40
1362Pairs of Songs With Total Durations Divisible by 60 LeetCode Solution40
1363Paint House LeetCode Solution39
1364Minimum Number of Arrows to Burst Balloons LeetCode Solution36
1365Sentence Screen Fitting LeetCode Solution36
1366Valid Triangle Number LeetCode Solution36
1367Flatten Binary Tree to Linked List LeetCode Solution36
1368Split Linked List in Parts Leetcode Solution35
1369Group Shifted Strings Leetcode Solution35
1370Isomorphic Strings LeetCode Solution35
1371Unique Binary Search Trees LeetCode Solution35
1372Next Greater Element I Leetcode Solution35
1373The Number of Weak Characters in the Game LeetCode Solution35
1374Count Good Nodes in Binary Tree LeetCode Solution34
1375Peak Index in a Mountain Array LeetCode Solution33
1376Insert Delete GetRandom O(1) – Duplicates allowed LeetCode Solution33
1377Swim in Rising Water LeetCode Solution32
1378Single Element in a Sorted Array LeetCode Solution31
1379Best Time to Buy and Sell Stock IV LeetCode Solution31
1380Closest Binary Search Tree Value II LeetCode Solution31
1381Max Sum of Two Non-Overlapping Subarrays LeetCode Solution29
1382Find First and Last Position of Element in Sorted Array LeetCode Solution29
1383Minimum Increment to Make Array Unique Leetcode Solution29
1384All Possible Full Binary Trees LeetCode Solution28
1385Validate Stack Sequences LeetCode Solution27
1386Lowest Common Ancestor of a Binary Search Tree Leetcode Solution27
1387Detect Squares LeetCode Solution26
1388Contains Duplicate LeetCode Solution25
1389Break a Palindrome LeetCode Solution25
1390Implement Rand10() Using Rand7() Leetcode Solution25
1391Trapping Rain Water II LeetCode Solution25
1392Greatest Sum Divisible by Three LeetCode Solution25
1393Implement strStr() LeetCode Solution25
1394Invert Binary Tree LeetCode Solution24
1395Stone Game IV LeetCode Solution24
1396Reverse Nodes in k-Group LeetCode Solution23
1397Remove All Ones With Row and Column Flips Leetcode Solution23
1398Fibonacci Number LeetCode Solution21
1399Design Bounded Blocking Queue LeetCode Solution21
1400Minimum Number of Operations to Move All Balls to Each Box LeetCode Solution20
1401Total Hamming Distance LeetCode Solution19
1402Candy LeetCode Solution18
1403Unique Paths III LeetCode Solution16
Translate »