Skip to content

All Python solutions for Leetcode

License

NotificationsYou must be signed in to change notification settings

cnkyrpsgl/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Leetcode Python solutions

About

This repository includes my solutions to all Leetcode algorithm questions. This problems mostly consist of real interview questions that are asked on big companies like Facebook, Amazon, , Google etc. If you find my solutions hard to comprehend, give yourself a time to solve easier questions or check discussion section to problem on LeetCode. Feel free to contact me for improvements 😃

Prerequisites

Some problems may need premium subscription on LeetCode to unlock it!

import premium

List of Problems

#ProblemSolution
1Two Sumpython3
2Add Two Numberspython3
3Longest Substring Without Repeating Characterspython3
4Median of Two Sorted Arrayspython3
5Longest Palindromic Substringpython3
6ZigZag Conversionpython3
7Reverse Integerpython3
8String to Integer (atoi)python3
9Palindrome Numberpython3
10Regular Expression Matchingpython3
11Container With Most Waterpython3
12Integer to Romanpython3
13Roman to Integerpython3
14Longest Common Prefixpython3
153Sumpython3
163Sum Closestpython3
17Letter Combinations of a Phone Numberpython3
184Sumpython3
19Remove Nth Node From End of Listpython3
20Valid Parenthesespython3
21Merge Two Sorted Listspython3
22Generate Parenthesespython3
23Merge k Sorted Listspython3
24Swap Nodes in Pairspython3
25Reverse Nodes in k-Grouppython3
26Remove Duplicates from Sorted Arraypython3
27Remove Elementpython3
28Implement strStr()python3
29Divide Two Integerspython3
30Substring with Concatenation of All Wordspython3
31Next Permutationpython3
32Longest Valid Parenthesespython3
33Search in Rotated Sorted Arraypython3
34Find First and Last Position of Element in Sorted Arraypython3
35Search Insert Positionpython3
36Valid Sudokupython3
37Sudoku Solverpython3
38Count and Saypython3
39Combination Sumpython3
40Combination Sum IIpython3
41First Missing Positivepython3
42Trapping Rain Waterpython3
43Multiply Stringspython3
44Wildcard Matchingpython3
45Jump Game IIpython3
46Permutationspython3
47Permutations IIpython3
48Rotate Imagepython3
49Group Anagramspython3
50Pow(x, n)python3
51N-Queenspython3
52N-Queens IIpython3
53Maximum Subarraypython3
54Spiral Matrixpython3
55Jump Gamepython3
56Merge Intervalspython3
57Insert Intervalpython3
58Length of Last Wordpython3
59Spiral Matrix IIpython3
60Permutation Sequencepython3
61Rotate Listpython3
62Unique Pathspython3
63Unique Paths IIpython3
64Minimum Path Sumpython3
65Valid Numberpython3
66Plus Onepython3
67Add Binarypython3
68Text Justificationpython3
69Sqrt(x)python3
70Climbing Stairspython3
71Simplify Pathpython3
72Edit Distancepython3
73Set Matrix Zeroespython3
74Search a 2D Matrixpython3
75Sort Colorspython3
76Minimum Window Substringpython3
77Combinationspython3
78Subsetspython3
79Word Searchpython3
80Remove Duplicates from Sorted Array IIpython3
81Search in Rotated Sorted Array IIpython3
82Remove Duplicates from Sorted List IIpython3
83Remove Duplicates from Sorted Listpython3
84Largest Rectangle in Histogrampython3
85Maximal Rectanglepython3
86Partition Listpython3
87Scramble Stringpython3
88Merge Sorted Arraypython3
89Gray Codepython3
90Subsets IIpython3
91Decode Wayspython3
92Reverse Linked List IIpython3
93Restore IP Addressespython3
94Binary Tree Inorder Traversalpython3
95Unique Binary Search Trees IIpython3
96Unique Binary Search Treespython3
97Interleaving Stringpython3
98Validate Binary Search Treepython3
99Recover Binary Search Treepython3
100Same Treepython3
101Symmetric Treepython3
102Binary Tree Level Order Traversalpython3
103Binary Tree Zigzag Level Order Traversalpython3
104Maximum Depth of Binary Treepython3
105Construct Binary Tree from Preorder and Inorder Traversalpython3
106Construct Binary Tree from Inorder and Postorder Traversalpython3
107Binary Tree Level Order Traversal IIpython3
108Convert Sorted Array to Binary Search Treepython3
109Convert Sorted List to Binary Search Treepython3
110Balanced Binary Treepython3
111Minimum Depth of Binary Treepython3
112Path Sumpython3
113Path Sum IIpython3
114Flatten Binary Tree to Linked Listpython3
115Distinct Subsequencespython3
116Populating Next Right Pointers in Each Nodepython3
117Populating Next Right Pointers in Each Node IIpython3
118Pascal's Trianglepython3
119Pascal's Triangle IIpython3
120Trianglepython3
121Best Time to Buy and Sell Stockpython3
122Best Time to Buy and Sell Stock IIpython3
123Best Time to Buy and Sell Stock IIIpython3
124Binary Tree Maximum Path Sumpython3
125Valid Palindromepython3
126Word Ladder IIpython3
127Word Ladderpython3
128Longest Consecutive Sequencepython3
129Sum Root to Leaf Numberspython3
130Surrounded Regionspython3
131Palindrome Partitioningpython3
132Palindrome Partitioning IIpython3
133Clone Graphpython3
134Gas Stationpython3
135Candypython3
136Single Numberpython3
137Single Number IIpython3
138Copy List with Random Pointerpython3
139Word Breakpython3
140Word Break IIpython3
141Linked List Cyclepython3
142Linked List Cycle IIpython3
143Reorder Listpython3
144Binary Tree Preorder Traversalpython3
145Binary Tree Postorder Traversalpython3
146LRU Cachepython3
147Insertion Sort Listpython3
148Sort Listpython3
149Max Points on a Linepython3
150Evaluate Reverse Polish Notationpython3
151Reverse Words in a Stringpython3
152Maximum Product Subarraypython3
153Find Minimum in Rotated Sorted Arraypython3
154Find Minimum in Rotated Sorted Array IIpython3
155Min Stackpython3
156Binary Tree Upside Downpython3
157Read N Characters Given Read4python3
158Read N Characters Given Read4 II - Call multiple timespython3
159Longest Substring with At Most Two Distinct Characterspython3
160Intersection of Two Linked Listspython
161One Edit Distancepython3
162Find Peak Elementpython3
163Missing Rangespython3
164Maximum Gappython3
165Compare Version Numberspython3
166Fraction to Recurring Decimalpython3
167Two Sum II - Input array is sortedpython3
168Excel Sheet Column Titlepython3
169Majority Elementpython3
170Two Sum III - Data structure designpython3
171Excel Sheet Column Numberpython3
172Factorial Trailing Zeroespython3
173Binary Search Tree Iteratorpython3
174Dungeon Gamepython3
179Largest Numberpython3
186Reverse Words in a String IIpython3
187Repeated DNA Sequencespython3
188Best Time to Buy and Sell Stock IVpython3
189Rotate Arraypython3
190Reverse Bitspython
198House Robberpython3
199Binary Tree Right Side Viewpython3
200Number of Islandspython3
201Bitwise AND of Numbers Rangepython3
202Happy Numberpython3
203Remove Linked List Elementspython3
204Count Primespython3
205Isomorphic Stringspython3
206Reverse Linked Listpython3
207Course Schedulepython3
208Implement Trie (Prefix Tree)python3
209Minimum Size Subarray Sumpython3
210Course Schedule IIpython3
211Add and Search Word - Data structure designpython3
212Word Search IIpython3
213House Robber IIpython3
214Shortest Palindromepython3
215Kth Largest Element in an Arraypython3
216Combination Sum IIIpython3
217Contains Duplicatepython3
218The Skyline Problempython3
219Contains Duplicate IIpython3
220Contains Duplicate IIIpython3
221Maximal Squarepython3
222Count Complete Tree Nodespython3
223Rectangle Areapython3
224Basic Calculatorpython3
225Implement Stack using Queuespython3
226Invert Binary Treepython3
227Basic Calculator IIpython3
228Summary Rangespython3
229Majority Element IIpython3
230Kth Smallest Element in a BSTpython3
231Power of Twopython3
232Implement Queue using Stackspython3
233Number of Digit Onepython3
234Palindrome Linked Listpython3
235Lowest Common Ancestor of a Binary Search Treepython3
236Lowest Common Ancestor of a Binary Treepython3
237Delete Node in a Linked Listpython3
238Product of Array Except Selfpython3
239Sliding Window Maximumpython3
240Search a 2D Matrix IIpython3
241Different Ways to Add Parenthesespython3
242Valid Anagrampython3
243Shortest Word Distancepython3
244Shortest Word Distance IIpython3
245Shortest Word Distance IIIpython3
246Strobogrammatic Numberpython3
247Strobogrammatic Number IIpython3
248Strobogrammatic Number IIIpython3
249Group Shifted Stringspython3
250Count Univalue Subtreespython3
251Flatten 2D Vectorpython3
252Meeting Roomspython3
253Meeting Rooms IIpython3
254Factor Combinationspython3
255Verify Preorder Sequence in Binary Search Treepython3
256Paint Housepython3
257Binary Tree Pathspython3
258Add Digitspython3
2593Sum Smallerpython3
260Single Number IIIpython3
261Graph Valid Treepython3
263Ugly Numberpython3
264Ugly Number IIpython3
265Paint House IIpython3
266Palindrome Permutationpython3
267Palindrome Permutation IIpython3
268Missing Numberpython3
269Alien Dictionarypython3
270Closest Binary Search Tree Valuepython3
271Encode and Decode Stringspython
272Closest Binary Search Tree Value IIpython3
273Integer to English Wordspython3
274H-Indexpython3
275H-Index IIpython3
276Paint Fencepython3
277Find the Celebritypython
278First Bad Versionpython3
279Perfect Squarespython3
280Wiggle Sortpython3
281Zigzag Iteratorpython
282Expression Add Operatorspython3
283Move Zeroespython3
284Peeking Iteratorpython3
285Inorder Successor in BSTpython3
286Walls and Gatespython3
287Find the Duplicate Numberpython3
288Unique Word Abbreviationpython3
289Game of Lifepython3
290Word Patternpython3
291Word Pattern IIpython3
292Nim Gamepython3
293Flip Gamepython3
294Flip Game IIpython3
295Find Median from Data Streampython3
296Best Meeting Pointpython3
297Serialize and Deserialize Binary Treepython3
298Binary Tree Longest Consecutive Sequencepython3
299Bulls and Cowspython3
300Longest Increasing Subsequencepython3
301Remove Invalid Parenthesespython3
302Smallest Rectangle Enclosing Black Pixelspython3
303Range Sum Query - Immutablepython3
304Range Sum Query 2D - Immutablepython3
305Number of Islands IIpython3
306Additive Numberpython3
307Range Sum Query - Mutablepython3
308Range Sum Query 2D - Mutablepython3
309Best Time to Buy and Sell Stock with Cooldownpython3
310Minimum Height Treespython3
311Sparse Matrix Multiplicationpython3
312Burst Balloonspython3
313Super Ugly Numberpython3
314Binary Tree Vertical Order Traversalpython3
315Count of Smaller Numbers After Selfpython3
316Remove Duplicate Letterspython3
317Shortest Distance from All Buildingspython3
318Maximum Product of Word Lengthspython3
319Bulb Switcherpython3
320Generalized Abbreviationpython3
321Create Maximum Numberpython3
322Coin Changepython3
323Number of Connected Components in an Undirected Graphpython3
324Wiggle Sort IIpython3
325Maximum Size Subarray Sum Equals kpython3
326Power of Threepython3
327Count of Range Sumpython3
328Odd Even Linked Listpython3
329Longest Increasing Path in a Matrixpython3
330ing Arraypython3
331Verify Preorder Serialization of a Binary Treepython3
332Reconstruct Itinerarypython3
333Largest BST Subtreepython3
334Increasing Triplet Subsequencepython3
335Self Crossingpython3
336Palindrome Pairspython3
337House Robber IIIpython3
338Counting Bitspython3
339Nested List Weight Sumpython3
340Longest Substring with At Most K Distinct Characterspython3
342Power of Fourpython3
343Integer Breakpython3
344Reverse Stringpython3
345Reverse Vowels of a Stringpython3
346Moving Average from Data Streampython3
347Top K Frequent Elementspython3
348Design Tic-Tac-Toepython3
349Intersection of Two Arrayspython3
350Intersection of Two Arrays IIpython3
351Android Unlock Patternspython3
352Data Stream as Disjoint Intervalspython3
353Design Snake Gamepython3
354Russian Doll Envelopespython3
355Design Twitterpython3
356Line Reflectionpython3
357Count Numbers with Unique Digitspython3
358Rearrange String k Distance Apartpython3
359Logger Rate Limiterpython3
360Sort Transformed Arraypython3
361Bomb Enemypython3
362Design Hit Counterpython3
363Max Sum of Rectangle No Larger Than Kpython3
364Nested List Weight Sum IIpython3
365Water and Jug Problempython3
366Find Leaves of Binary Treepython3
367Valid Perfect Squarepython3
368Largest Divisible Subsetpython3
369Plus One Linked Listpython3
370Range Additionpython3
371Sum of Two Integerspython3
372Super Powpython3
373Find K Pairs with Smallest Sumspython3
374Guess Number Higher or Lowerpython
375Guess Number Higher or Lower IIpython3
376Wiggle Subsequencepython3
377Combination Sum IVpython3
378Kth Smallest Element in a Sorted Matrixpython3
379Design Phone Directorypython3
380Insert Delete GetRandom O(1)python3
381Insert Delete GetRandom O(1) - Duplicates allowedpython3
382Linked List Random Nodepython3
383Ransom Notepython3
384Shuffle an Arraypython3
385Mini Parserpython3
386Lexicographical Numberspython3
387First Unique Character in a Stringpython3
388Longest Absolute File Pathpython3
389Find the Differencepython3
390Elimination Gamepython3
391Perfect Rectanglepython3
392Is Subsequencepython3
393UTF-8 Validationpython3
394Decode Stringpython3
395Longest Substring with At Least K Repeating Characterspython3
396Rotate Functionpython3
397Integer Replacementpython3
398Random Pick Indexpython3
399Evaluate Divisionpython3
400Nth Digitpython
401Binary Watchpython3
402Remove K Digitspython3
403Frog Jumppython3
404Sum of Left Leavespython3
405Convert a Number to Hexadecimalpython3
406Queue Reconstruction by Heightpython3
407Trapping Rain Water IIpython3
408Valid Word Abbreviationpython3
409Longest Palindromepython3
410Split Array Largest Sumpython3
411Minimum Unique Word Abbreviationpython3
412Fizz Buzzpython3
413Arithmetic Slicespython3
414Third Maximum Numberpython3
415Add Stringspython3
416Partition Equal Subset Sumpython3
417Pacific Atlantic Water Flowpython3
418Sentence Screen Fittingpython3
419Battleships in a Boardpython3
420Strong Password Checkerpython3
421Maximum XOR of Two Numbers in an Arraypython3
422Valid Word Squarepython3
423Reconstruct Original Digits from Englishpython
424Longest Repeating Character Replacementpython3
425Word Squarespython3
426Convert Binary Search Tree to Sorted Doubly Linked Listpython3
427Construct Quad Treepython3
428Serialize and Deserialize N-ary Treepython
429N-ary Tree Level Order Traversalpython
430Flatten a Multilevel Doubly Linked Listpython
431Encode N-ary Tree to Binary Treepython
432All O`one Data Structurepython3
433Minimum Genetic Mutationpython3
434Number of Segments in a Stringpython3
435Non-overlapping Intervalspython3
436Find Right Intervalpython3
437Path Sum IIIpython3
438Find All Anagrams in a Stringpython3
439Ternary Expression Parserpython3
440K-th Smallest in Lexicographical Orderpython
441Arranging Coinspython3
442Find All Duplicates in an Arraypython3
443String Compressionpython3
444Sequence Reconstructionpython3
445Add Two Numbers IIpython3
446Arithmetic Slices II - Subsequencepython3
447Number of Boomerangspython
448Find All Numbers Disappeared in an Arraypython3
449Serialize and Deserialize BSTpython
450Delete Node in a BSTpython3
451Sort Characters By Frequencypython3
452Minimum Number of Arrows to Burst Balloonspython3
453Minimum Moves to Equal Array Elementspython3
4544Sum IIpython3
455Assign Cookiespython3
456132 Patternpython3
457Circular Array Looppython
458Poor Pigspython
459Repeated Substring Patternpython3
460LFU Cachepython3
461Hamming Distancepython3
462Minimum Moves to Equal Array Elements IIpython3
463Island Perimeterpython3
464Can I Winpython3
465Optimal Account Balancingpython3
466Count The Repetitionspython3
467Unique Substrings in Wraparound Stringpython3
468Validate IP Addresspython3
469Convex Polygonpython3
470Implement Rand10() Using Rand7()python3
471Encode String with Shortest Lengthpython3
472Concatenated Wordspython3
473Matchsticks to Squarepython3
474Ones and Zeroespython3
475Heaterspython3
476Number Complementpython3
477Total Hamming Distancepython3
478Generate Random Point in a Circlepython3
479Largest Palindrome Productpython3
480Sliding Window Medianpython3
481Magical Stringpython3
482Formattingpython3
483Smallest Good Basepython3
484Find Permutationpython3
485Max Consecutive Onespython3
486Predict the Winnerpython3
487Max Consecutive Ones IIpython3
488Zuma Gamepython3
489Robot Room Cleanerpython3
490The Mazepython3
491Increasing Subsequencespython3
492Construct the Rectanglepython3
493Reverse Pairspython3
494Target Sumpython3
495Teemo Attackingpython3
496Next Greater Element Ipython3
497Random Point in Non-overlapping Rectanglespython3
498Diagonal Traversepython3
499The Maze IIIpython3
500Keyboard Rowpython3
501Find Mode in Binary Search Treepython3
502IPOpython3
503Next Greater Element IIpython3
504Base 7python3
505The Maze IIpython3
506Relative Rankspython3
507Perfect Numberpython3
508Most Frequent Subtree Sumpython3
509Fibonacci Numberpython3
510Inorder Successor in BST IIpython3
513Find Bottom Left Tree Valuepython3
514Freedom Trailpython3
515Find Largest Value in Each Tree Rowpython3
516Longest Palindromic Subsequencepython3
517Super Washing Machinespython3
518Coin Change 2python
519Random Flip Matrixpython3
520Detect Capitalpython3
521Longest Uncommon Subsequence Ipython3
522Longest Uncommon Subsequence IIpython3
523Continuous Subarray Sumpython3
524Longest Word in Dictionary through Deletingpython3
525Contiguous Arraypython3
526Beautiful Arrangementpython3
527Word Abbreviationpython3
528Random Pick with Weightpython3
529Minesweeperpython3
530Minimum Absolute Difference in BSTpython3
531Lonely Pixel Ipython3
532K-diff Pairs in an Arraypython3
533Lonely Pixel IIpython3
535Encode and Decode TinyURLpython
536Construct Binary Tree from Stringpython3
537Complex Number Multiplicationpython3
538Convert BST to Greater Treepython3
539Minimum Time Differencepython3
540Single Element in a Sorted Arraypython3
541Reverse String IIpython3
54201 Matrixpython3
543Diameter of Binary Treepython3
544Output Contest Matchespython3
545Boundary of Binary Treepython3
546Remove Boxespython3
547Friend Circlespython3
548Split Array with Equal Sumpython
549Binary Tree Longest Consecutive Sequence IIpython3
551Student Attendance Record Ipython3
552Student Attendance Record IIpython
553Optimal Divisionpython3
554Brick Wallpython3
555Split Concatenated Stringspython3
556Next Greater Element IIIpython3
557Reverse Words in a String IIIpython3
558Quad Tree Intersectionpython3
559Maximum Depth of N-ary Treepython
560Subarray Sum Equals Kpython3
561Array Partition Ipython3
562Longest Line of Consecutive One in Matrixpython3
563Binary Tree Tiltpython3
564Find the Closest Palindromepython3
565Array Nestingpython3
566Reshape the Matrixpython3
567Permutation in Stringpython3
568Maximum Vacation Dayspython3
572Subtree of Another Treepython3
573Squirrel Simulationpython3
575Distribute Candiespython3
576Out of Boundary Pathspython3
581Shortest Unsorted Continuous Subarraypython3
582Kill Processpython3
583Delete Operation for Two Stringspython3
587Erect the Fencepython3
588Design In-Memory File Systempython3
589N-ary Tree Preorder Traversalpython
590N-ary Tree Postorder Traversalpython
591Tag Validatorpython3
592Fraction Addition and Subtractionpython3
593Valid Squarepython3
594Longest Harmonious Subsequencepython
598Range Addition IIpython3
599Minimum Index Sum of Two Listspython3
600Non-negative Integers without Consecutive Onespython3
604Design Compressed String Iteratorpython3
605Can Place Flowerspython3
606Construct String from Binary Treepython3
609Find Duplicate File in Systempython3
611Valid Triangle Numberpython3
616Add Bold Tag in Stringpython3
617Merge Two Binary Treespython3
621Task Schedulerpython3
622Design Circular Queuepython3
623Add One Row to Treepython3
624Maximum Distance in Arrayspython3
625Minimum Factorizationpython3
628Maximum Product of Three Numberspython3
629K Inverse Pairs Arraypython3
630Course Schedule IIIpython3
631Design Excel Sum Formulapython3
632Smallest Range Covering Elements from K Listspython3
633Sum of Square Numberspython3
634Find the Derangement of An Arraypython
635Design Log Storage Systempython3
636Exclusive Time of Functionspython3
637Average of Levels in Binary Treepython3
638Shopping Offerspython3
639Decode Ways IIpython3
640Solve the Equationpython3
641Design Circular Dequepython3
642Design Search Autocomplete Systempython3
643Maximum Average Subarray Ipython3
644Maximum Average Subarray IIpython3
645Set Mismatchpython3
646Maximum Length of Pair Chainpython3
647Palindromic Substringspython3
648Replace Wordspython3
649Dota2 Senatepython3
6502 Keys Keyboardpython3
6514 Keys Keyboardpython3
652Find Duplicate Subtreespython3
653Two Sum IV - Input is a BSTpython3
654Maximum Binary Treepython3
655Print Binary Treepython3
656Coin Pathpython3
657Robot Return to Originpython3
658Find K Closest Elementspython3
659Split Array into Consecutive Subsequencespython3
660Remove 9python3
661Image Smootherpython3
662Maximum Width of Binary Treepython3
663Equal Tree Partitionpython3
664Strange Printerpython3
665Non-decreasing Arraypython3
666Path Sum IVpython3
667Beautiful Arrangement IIpython3
668Kth Smallest Number in Multiplication Tablepython3
669Trim a Binary Search Treepython3
670Maximum Swappython3
671Second Minimum Node In a Binary Treepython3
672Bulb Switcher IIpython3
673Number of Longest Increasing Subsequencepython3
674Longest Continuous Increasing Subsequencepython3
675Cut Off Trees for Golf Eventpython3
676Implement Magic Dictionarypython3
677Map Sum Pairspython3
678Valid Parenthesis Stringpython3
67924 Gamepython3
680Valid Palindrome IIpython3
681Next Closest Timepython3
682Baseball Gamepython3
683K Empty Slotspython
684Redundant Connectionpython3
685Redundant Connection IIpython3
686Repeated String Matchpython3
687Longest Univalue Pathpython
688Knight Probability in Chessboardpython3
689Maximum Sum of 3 Non-Overlapping Subarrayspython3
690Employee Importancepython3
691Stickers to Spell Wordpython3
692Top K Frequent Wordspython3
693Binary Number with Alternating Bitspython3
694Number of Distinct Islandspython3
695Max Area of Islandpython3
696Count Binary Substringspython3
697Degree of an Arraypython3
698Partition to K Equal Sum Subsetspython3
699Falling Squarespython3
700Search in a Binary Search Treepython3
701Insert into a Binary Search Treepython3
702Search in a Sorted Array of Unknown Sizepython3
703Kth Largest Element in a Streampython3
704Binary Searchpython3
705Design HashSetpython3
706Design HashMappython3
707Design Linked Listpython3
708Insert into a Cyclic Sorted Listpython
709To Lower Casepython3
710Random Pick with Blacklistpython3
711Number of Distinct Islands IIpython3
712Minimum ASCII Delete Sum for Two Stringspython3
713Subarray Product Less Than Kpython3
714Best Time to Buy and Sell Stock with Transaction Feepython3
715Range Modulepython3
716Max Stackpython3
7171-bit and 2-bit Characterspython3
718Maximum Length of Repeated Subarraypython3
719Find K-th Smallest Pair Distancepython3
720Longest Word in Dictionarypython3
721Accounts Mergepython3
722Remove Commentspython3
723Candy Crushpython3
724Find Pivot Indexpython3
725Split Linked List in Partspython3
726Number of Atomspython3
727Minimum Window Subsequencepython3
728Self Dividing Numberspython3
729My Calendar Ipython3
730Count Different Palindromic Subsequencespython3
731My Calendar IIpython3
732My Calendar IIIpython3
733Flood Fillpython3
734Sentence Similaritypython3
735Asteroid Collisionpython3
736Parse Lisp Expressionpython3
737Sentence Similarity IIpython3
738Monotone Increasing Digitspython3
739Daily Temperaturespython3
740Delete and Earnpython3
741Cherry Pickuppython3
742Closest Leaf in a Binary Treepython3
743Network Delay Timepython3
744Find Smallest Letter Greater Than Targetpython3
745Prefix and Suffix Searchpython3
746Min Cost Climbing Stairspython3
747Largest Number At Least Twice of Otherspython3
748Shortest Completing Wordpython3
749Contain Viruspython3
750Number Of Corner Rectanglespython3
751IP to CIDRpython3
752Open the Lockpython3
753ing the Safepython3
754Reach a Numberpython3
755Pour Waterpython3
756Pyramid Transition Matrixpython3
757Set Intersection Size At Least Twopython3
758Bold Words in Stringpython3
759Employee Free Timepython3
760Find Anagram Mappingspython3
761Special Binary Stringpython3
762Prime Number of Set Bits in Binary Representationpython3
763Partition Labelspython3
764Largest Plus Signpython3
765Couples Holding Handspython3
766Toeplitz Matrixpython3
767Reorganize Stringpython3
768Max Chunks To Make Sorted IIpython3
769Max Chunks To Make Sortedpython3
770Basic Calculator IVpython3
771Jewels and Stonespython3
772Basic Calculator IIIpython3
773Sliding Puzzlepython3
774Minimize Max Distance to Gas Stationpython3
775Global and Local Inversionspython3
776Split BSTpython3
777Swap Adjacent in LR Stringpython3
778Swim in Rising Waterpython3
779K-th Symbol in Grammarpython3
780Reaching Pointspython3
781Rabbits in Forestpython3
782Transform to Chessboardpython3
783Minimum Distance Between BST Nodespython3
784Letter Case Permutationpython3
785Is Graph Bipartite?python3
786K-th Smallest Prime Fractionpython3
787Cheapest Flights Within K Stopspython3
788Rotated Digitspython3
789Escape The Ghostspython3
790Domino and Tromino Tilingpython
791Custom Sort Stringpython3
792Number of Matching Subsequencespython3
793Preimage Size of Factorial Zeroes Functionpython3
794Valid Tic-Tac-Toe Statepython3
795Number of Subarrays with Bounded Maximumpython3
796Rotate Stringpython
797All Paths From Source to Targetpython3
798Smallest Rotation with Highest Scorepython3
799Champagne Towerpython3
800Similar RGB Colorpython3
802Find Eventual Safe Statespython3
803Bricks Falling When Hitpython3
804Unique Morse Code Wordspython3
805Split Array With Same Averagepython3
806Number of Lines To Write Stringpython3
807Max Increase to Keep City Skylinepython3
808Soup Servingspython3
809Expressive Wordspython3
810Chalkboard XOR Gamepython3
811Subdomain Visit Countpython3
812Largest Triangle Areapython3
813Largest Sum of Averagespython3
814Binary Tree Pruningpython3
815Bus Routespython3
816Ambiguous Coordinatespython3
817Linked List Componentspython3
818Race Carpython3
819Most Common Wordpython3
820Short Encoding of Wordspython3
821Shortest Distance to a Characterpython3
822Card Flipping Gamepython3
823Binary Trees With Factorspython3
824Goat Latinpython3
825Friends Of Appropriate Agespython3
826Most Profit Assigning Workpython3
827Making A Large Islandpython3
828Unique Letter Stringpython3
829Consecutive Numbers Sumpython3
830Positions of Large Groupspython3
831Masking Personal Informationpython3
832Flipping an Imagepython3
833Find And Replace in Stringpython3
834Sum of Distances in Treepython3
835Image Overlappython3
836Rectangle Overlappython3
837New 21 Gamepython3
838Push Dominoespython3
839Similar String Groupspython3
840Magic Squares In Gridpython3
841Keys and Roomspython3
842Split Array into Fibonacci Sequencepython3
843Guess the Wordpython3
844Backspace String Comparepython3
845Longest Mountain in Arraypython3
846Hand of Straightspython3
847Shortest Path Visiting All Nodespython3
848Shifting Letterspython3
849Maximize Distance to Closest Personpython3
850Rectangle Area IIpython3
851Loud and Richpython3
852Peak Index in a Mountain Arraypython3
853Car Fleetpython3
854K-Similar Stringspython3
855Exam Roompython3
856Score of Parenthesespython3
857Minimum Cost to Hire K Workerspython3
858Mirror Reflectionpython3
859Buddy Stringspython3
860Lemonade Changepython3
861Score After Flipping Matrixpython3
862Shortest Subarray with Sum at Least Kpython3
863All Nodes Distance K in Binary Treepython3
864Shortest Path to Get All Keyspython3
865Smallest Subtree with all the Deepest Nodespython3
866Prime Palindromepython3
867Transpose Matrixpython3
868Binary Gappython3
869Reordered Power of 2python3
870Advantage Shufflepython3
871Minimum Number of Refueling Stopspython3
872Leaf-Similar Treespython3
873Length of Longest Fibonacci Subsequencepython3
874Walking Robot Simulationpython3
875Koko Eating Bananaspython3
876Middle of the Linked Listpython3
877Stone Gamepython3
878Nth Magical Numberpython3
879Profitable Schemespython3
880Decoded String at Indexpython3
881Boats to Save Peoplepython3
882Reachable Nodes In Subdivided Graphpython3
883Projection Area of 3D Shapespython3
884Uncommon Words from Two Sentencespython3
885Spiral Matrix IIIpython3
886Possible Bipartitionpython3
887Super Egg Droppython3
888Fair Candy Swappython3
889Construct Binary Tree from Preorder and Postorder Traversalpython3
890Find and Replace Patternpython3
891Sum of Subsequence Widthspython3
892Surface Area of 3D Shapespython3
893Groups of Special-Equivalent Stringspython3
894All Possible Full Binary Treespython3
895Maximum Frequency Stackpython3
896Monotonic Arraypython3
897Increasing Order Search Treepython3
898Bitwise ORs of Subarrayspython3
899Orderly Queuepython3
900RLE Iteratorpython3
901Online Stock Spanpython3
902Numbers At Most N Given Digit Setpython3
903Valid Permutations for DI Sequencepython3
904Fruit Into Basketspython3
905Sort Array By Paritypython3
906Super Palindromespython3
907Sum of Subarray Minimumspython3
908Smallest Range Ipython3
909Snakes and Ladderspython3
910Smallest Range IIpython3
911Online Electionpython3
912Sort an Arraypython3
913Cat and Mousepython3
914X of a Kind in a Deck of Cardspython3
915Partition Array into Disjoint Intervalspython3
916Word Subsetspython3
917Reverse Only Letterspython3
918Maximum Sum Circular Subarraypython3
919Complete Binary Tree Inserterpython3
920Number of Music Playlistspython3
921Minimum Add to Make Parentheses Validpython3
922Sort Array By Parity IIpython3
9233Sum With Multiplicitypython3
924Minimize Malware Spreadpython3
925Long Pressed Namepython3
926Flip String to Monotone Increasingpython3
927Three Equal Partspython3
928Minimize Malware Spread IIpython3
929Unique Email Addressespython3
930Binary Subarrays With Sumpython3
931Minimum Falling Path Sumpython3
932Beautiful Arraypython3
933Number of Recent Callspython3
934Shortest Bridgepython3
935Knight Dialerpython3
936Stamping The Sequencepython3
937Reorder Data in Log Filespython3
938Range Sum of BSTpython3
939Minimum Area Rectanglepython3
940Distinct Subsequences IIpython3
941Valid Mountain Arraypython3
942DI String Matchpython3
943Find the Shortest Superstringpython3
944Delete Columns to Make Sortedpython3
945Minimum Increment to Make Array Uniquepython3
946Validate Stack Sequencespython3
947Most Stones Removed with Same Row or Columnpython3
948Bag of Tokenspython3
949Largest Time for Given Digitspython3
950Reveal Cards In Increasing Orderpython3
951Flip Equivalent Binary Treespython3
952Largest Component Size by Common Factorpython3
953Verifying an Alien Dictionarypython3
954Array of Doubled Pairspython3
955Delete Columns to Make Sorted IIpython3
956Tallest Billboardpython3
957Prison Cells After N Dayspython3
958Check Completeness of a Binary Treepython3
959Regions Cut By Slashespython3
960Delete Columns to Make Sorted IIIpython3
961N-Repeated Element in Size 2N Arraypython3
962Maximum Width Ramppython3
963Minimum Area Rectangle IIpython3
964Least Operators to Express Numberpython3
965Univalued Binary Treepython3
966Vowel Spellcheckerpython3
967Numbers With Same Consecutive Differencespython3
968Binary Tree Cameraspython3
969Pancake Sortingpython3
970Powerful Integerspython3
971Flip Binary Tree To Match Preorder Traversalpython3
972Equal Rational Numberspython3
973K Closest Points to Originpython3
974Subarray Sums Divisible by Kpython3
975Odd Even Jumppython3
976Largest Perimeter Trianglepython3
977Squares of a Sorted Arraypython3
978Longest Turbulent Subarraypython3
979Distribute Coins in Binary Treepython3
980Unique Paths IIIpython3
981Time Based Key-Value Storepython3
982Triples with Bitwise AND Equal To Zeropython3
983Minimum Cost For Ticketspython3
984String Without AAA or BBBpython3
985Sum of Even Numbers After Queriespython3
986Interval List Intersectionspython3
987Vertical Order Traversal of a Binary Treepython3
988Smallest String Starting From Leafpython3
989Add to Array-Form of Integerpython3
990Satisfiability of Equality Equationspython3
991Broken Calculatorpython3
992Subarrays with K Different Integerspython
993Cousins in Binary Treepython3
994Rotting Orangespython3
995Minimum Number of K Consecutive Bit Flipspython3
996Number of Squareful Arrayspython3
997Find the Town Judgepython3
998Maximum Binary Tree IIpython3
999Available Captures for Rookpython3
1000Minimum Cost to Merge Stonespython3
1001Grid Illuminationpython3
1002Find Common Characterspython3
1003Check If Word Is Valid After Substitutionspython3
1004Max Consecutive Ones IIIpython3
1005Maximize Sum Of Array After K Negationspython3
1006Clumsy Factorialpython3
1007Minimum Domino Rotations For Equal Rowpython3
1008Construct Binary Search Tree from Preorder Traversalpython3
1009Complement of Base 10 Integerpython3
1010Pairs of Songs With Total Durations Divisible by 60python3
1011Capacity To Ship Packages Within D Dayspython3
1012Numbers With Repeated Digitspython3
1013Partition Array Into Three Parts With Equal Sumpython3
1014Best Sightseeing Pairpython3
1015Smallest Integer Divisible by Kpython3
1016Binary String With Substrings Representing 1 To Npython3
1017Convert to Base -2python3
1018Binary Prefix Divisible By 5python3
1019Next Greater Node In Linked Listpython3
1020Number of Enclavespython3
1021Remove Outermost Parenthesespython3
1022Sum of Root To Leaf Binary Numberspython3
1023Camelcase Matchingpython3
1024Video Stitchingpython3
1025Divisor Gamepython3
1026Maximum Difference Between Node and Ancestorpython3
1027Longest Arithmetic Sequencepython3
1028Recover a Tree From Preorder Traversalpython3
1029Two City Schedulingpython3
1030Matrix Cells in Distance Orderpython3
1031Maximum Sum of Two Non-Overlapping Subarrayspython3
1032Stream of Characterspython3
1033Moving Stones Until Consecutivepython3
1034Coloring A Borderpython3
1035Uncrossed Linespython3
1036Escape a Large Mazepython3
1037Valid Boomerangpython3
1038Binary Search Tree to Greater Sum Treepython3
1039Minimum Score Triangulation of Polygonpython3
1040Moving Stones Until Consecutive IIpython3
1041Robot Bounded In Circlepython3
1042Flower Planting With No Adjacentpython3
1043Partition Array for Maximum Sumpython3
1044Longest Duplicate Substringpython3
1046Last Stone Weightpython3
1047Remove All Adjacent Duplicates In Stringpython3
1048Longest String Chainpython3
1049Last Stone Weight IIpython3
1051Height Checkerpython3
1052Grumpy Bookstore Ownerpython3
1053Previous Permutation With One Swappython3
1054Distant Barcodespython3
1055Shortest Way to Form Stringpython3
1056Confusing Numberpython3
1057Campus Bikespython3
1058Minimize Rounding Error to Meet Targetpython3
1059All Paths from Source Lead to Destinationpython3
1060Missing Element in Sorted Arraypython3
1061Lexicographically Smallest Equivalent Stringpython3
1062Longest Repeating Substringpython3
1063Number of Valid Subarrayspython3
1064Fixed Pointpython3
1065Index Pairs of a Stringpython3
1066Campus Bikes IIpython3
1071Greatest Common Divisor of Stringspython3
1072Flip Columns For Maximum Number of Equal Rowspython3
1074Number of Submatrices That Sum to Targetpython3
1078Occurrences After Bigrampython3
1079Letter Tile Possibilitiespython3
1080Insufficient Nodes in Root to Leaf Pathspython3
1081Smallest Subsequence of Distinct Characterspython3
1085Sum of Digits in the Minimum Numberpython3
1086High Fivepython3
1087Brace Expansionpython3
1088Confusing Number IIpython3
1089Duplicate Zerospython3
1090Largest Values From Labelspython3
1091Shortest Path in Binary Matrixpython3
1092Shortest Common Supersequencepython3
1093Statistics from a Large Samplepython3
1094Car Poolingpython3
1095Find in Mountain Arraypython3
1096Brace Expansion IIpython3
1099Two Sum Less Than Kpython3
1100Find K-Length Substrings With No Repeated Characterspython3
1101The Earliest Moment When Everyone Become Friendspython3
1102Path With Maximum Minimum Valuepython3
1103Distribute Candies to Peoplepython3
1104Path In Zigzag Labelled Binary Treepython3
1105Filling Bookcase Shelvespython3
1106Parsing A Boolean Expressionpython3
1108Defanging an IP Addresspython3
1109Corporate Flight Bookingspython3
1110Delete Nodes And Return Forestpython3
1111Maximum Nesting Depth of Two Valid Parentheses Stringspython3
1118Number of Days in a Monthpython3
1119Remove Vowels from a Stringpython3
1120Maximum Average Subtreepython3
1121Divide Array Into Increasing Sequencespython3
1122Relative Sort Arraypython3
1123Lowest Common Ancestor of Deepest Leavespython3
1124Longest Well-Performing Intervalpython3
1125Smallest Sufficient Teampython3
1128Number of Equivalent Domino Pairspython3
1129Shortest Path with Alternating Colorspython3
1130Minimum Cost Tree From Leaf Valuespython3
1131Maximum of Absolute Value Expressionpython3
1133Largest Unique Numberpython3
1134Armstrong Numberpython3
1135Connecting Cities With Minimum Costpython3
1136Parallel Coursespython3
1137N-th Tribonacci Numberpython3
1138Alphabet Board Pathpython3
1139Largest 1-Bordered Squarepython3
1140Stone Game IIpython3
1143Longest Common Subsequencepython3
1144Decrease Elements To Make Array Zigzagpython3
1145Binary Tree Coloring Gamepython3
1146Snapshot Arraypython3
1147Longest Chunked Palindrome Decompositionpython3
1150Check If a Number Is Majority Element in a Sorted Arraypython3
1151Minimum Swaps to Group All 1's Togetherpython3
1152Analyze User Website Visit Patternpython3
1153String Transforms Into Another Stringpython3
1154Day of the Yearpython3
1155Number of Dice Rolls With Target Sumpython3
1156Swap For Longest Repeated Character Substringpython3
1157Online Majority Element In Subarraypython3
1160Find Words That Can Be Formed by Characterspython3
1161Maximum Level Sum of a Binary Treepython3
1162As Far from Land as Possiblepython3
1163Last Substring in Lexicographical Orderpython3
1165Single-Row Keyboardpython3
1166Design File Systempython3
1167Minimum Cost to Connect Stickspython3
1168Optimize Water Distribution in a Villagepython3
1169Invalid Transactionspython3
1170Compare Strings by Frequency of the Smallest Characterpython3
1172Dinner Plate Stackspython3
1175Prime Arrangementspython3
1176Diet Plan Performancepython3
1177Can Make Palindrome from Substringpython3
1178Number of Valid Words for Each Puzzlepython3
1180Count Substrings with Only One Distinct Letterpython3
1181Before and After Puzzlepython3
1182Shortest Distance to Target Colorpython3
1184Distance Between Bus Stopspython3
1185Day of the Weekpython3
1186Maximum Subarray Sum with One Deletionpython3
1187Make Array Strictly Increasingpython3
1189Maximum Number of Balloonspython3
1190Reverse Substrings Between Each Pair of Parenthesespython3
1191K-Concatenation Maximum Sumpython3
1196How Many Apples Can You Put into the Basketpython3
1197Minimum Knight Movespython3
1198Find Smallest Common Element in All Rowspython3
1199Minimum Time to Build Blockspython3
1200Minimum Absolute Differencepython3
1201Ugly Number IIIpython3
1202Smallest String With Swapspython3
1203Sort Items by Groups Respecting Dependenciespython3
1207Unique Number of Occurrencespython3
1208Get Equal Substrings Within Budgetpython3
1209Remove All Adjacent Duplicates in String IIpython3
1210Minimum Moves to Reach Target with Rotationspython3
1213Intersection of Three Sorted Arrayspython3
1214Two Sum BSTspython3
1215Stepping Numberspython3
1216Valid Palindrome IIIpython3
1217Play with Chipspython3
1218Longest Arithmetic Subsequence of Given Differencepython3
1219Path with Maximum Goldpython3
1220Count Vowels Permutationpython3
1221Split a String in Balanced Stringspython3
1222Queens That Can Attack the Kingpython3
1223Dice Roll Simulationpython3
1224Maximum Equal Frequencypython3
1227Airplane Seat Assignment Probabilitypython3
1228Missing Number In Arithmetic Progressionpython3
1229Meeting Schedulerpython3
1230Toss Strange Coinspython3
1231Divide Chocolatepython3
1232Check If It Is a Straight Linepython3
1233Remove Sub-Folders from the Filesystempython3
1234Replace the Substring for Balanced Stringpython3
1235Maximum Profit in Job Schedulingpython3
1236Web Crawlerpython3
1237Find Positive Integer Solution for a Given Equationpython3
1238Circular Permutation in Binary Representationpython3
1239Maximum Length of a Concatenated String with Unique Characterspython3
1240Tiling a Rectangle with the Fewest Squarespython3
1243Array Transformationpython3
1244Design A Leaderboardpython3
1245Tree Diameterpython3
1246Palindrome Removalpython3
1247Minimum Swaps to Make Strings Equalpython3
1248Count Number of Nice Subarrayspython3
1249Minimum Remove to Make Valid Parenthesespython3
1250Check If It Is a Good Arraypython3
1252Cells with Odd Values in a Matrixpython3
1253Reconstruct a 2-Row Binary Matrixpython3
1254Number of Closed Islandspython3
1255Maximum Score Words Formed by Letterspython3
1256Encode Numberpython3
1257Smallest Common Regionpython3
1258Synonymous Sentencespython3
1259Handshakes That Don't Crosspython3
1260Shift 2D Gridpython3
1261Find Elements in a Contaminated Binary Treepython3
1262Greatest Sum Divisible by Threepython3
1263Minimum Moves to Move a Box to Their Target Locationpython3

Built With

Contributing

Please open a pull request if you need!

Author

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Thank you for anyone sharing invaluable ideas on discussions on Leetcode 🙌

Releases

No releases published

Packages

No packages published