Skip to content

franklingu/leetcode-solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions

Build Status

Introduction

LeetCode is a very good website to sharpen your programming/problem-solving skills. Of course, not all solutions here are optimal and your suggestions and contributions are welcomed.

Contents

# Title Solution Difficulty
1 Two Sum Java,Python Easy
2 Add Two Numbers Java,Python Medium
3 Longest Substring Without Repeating Characters Java,Python Medium
4 Median of Two Sorted Arrays Python Hard
5 Longest Palindromic Substring Python Medium
6 Zigzag Conversion Python Medium
7 Reverse Integer Java Medium
8 String to Integer (atoi) Python Medium
9 Palindrome Number Java Easy
10 Regular Expression Matching Python Hard
11 Container With Most Water Java,Python Medium
12 Integer to Roman Java Medium
13 Roman to Integer Java Easy
14 Longest Common Prefix Java Easy
15 3Sum Java,Python Medium
16 3Sum Closest Java Medium
17 Letter Combinations of a Phone Number Java Medium
18 4Sum Python Medium
19 Remove Nth Node From End of List Java Medium
20 Valid Parentheses Java Easy
21 Merge Two Sorted Lists Java,Python Easy
22 Generate Parentheses Java Medium
23 Merge k Sorted Lists Python Hard
24 Swap Nodes in Pairs Java Medium
25 Reverse Nodes in k-Group Python Hard
26 Remove Duplicates from Sorted Array Java Easy
27 Remove Element Java Easy
28 Find the Index of the First Occurrence in a String Python Medium
29 Divide Two Integers Python Medium
31 Next Permutation Python Medium
32 Longest Valid Parentheses Python Hard
33 Search in Rotated Sorted Array Java,Python Medium
34 Find First and Last Position of Element in Sorted Array Python Medium
35 Search Insert Position Java,Python Easy
36 Valid Sudoku Java Medium
37 Sudoku Solver Python Hard
38 Count and Say Java Medium
39 Combination Sum Java,Python Medium
40 Combination Sum II Python Medium
41 First Missing Positive Python Hard
42 Trapping Rain Water Python Hard
43 Multiply Strings Java Medium
44 Wildcard Matching Java Hard
45 Jump Game II Python Medium
46 Permutations Java,Python Medium
47 Permutations II Python Medium
48 Rotate Image Python Medium
49 Group Anagrams Python Medium
50 Pow(x, n) Python Medium
51 N-Queens Python Hard
52 N-Queens II Python Hard
53 Maximum Subarray Java,Python Medium
54 Spiral Matrix Java,Python Medium
55 Jump Game Java Medium
56 Merge Intervals Python Medium
57 Insert Interval Python Medium
58 Length of Last Word Java Easy
59 Spiral Matrix II Python Medium
60 Permutation Sequence Python Hard
61 Rotate List Java,Python Medium
62 Unique Paths Python Medium
63 Unique Paths II Python Medium
64 Minimum Path Sum Python Medium
65 Valid Number Python Hard
66 Plus One Java Easy
67 Add Binary Java Easy
69 Sqrt(x) C++,Python Easy
70 Climbing Stairs Java Easy
71 Simplify Path Python Medium
72 Edit Distance Java,C++ Hard
73 Set Matrix Zeroes Java Medium
74 Search a 2D Matrix Java Medium
75 Sort Colors Java,Python Medium
76 Minimum Window Substring Python Hard
77 Combinations Java,Python Medium
78 Subsets Python Medium
79 Word Search Python Medium
80 Remove Duplicates from Sorted Array II Java Medium
81 Search in Rotated Sorted Array II Python Medium
82 Remove Duplicates from Sorted List II Java,C++,Python Medium
83 Remove Duplicates from Sorted List Java,Python Easy
84 Largest Rectangle in Histogram Python Hard
85 Maximal Rectangle Python Hard
86 Partition List Python Medium
88 Merge Sorted Array Java Easy
89 Gray Code Python Medium
90 Subsets II Python Medium
91 Decode Ways Python Medium
92 Reverse Linked List II Java Medium
93 Restore IP Addresses Python Medium
94 Binary Tree Inorder Traversal Python Easy
95 Unique Binary Search Trees II Python Medium
96 Unique Binary Search Trees Python Medium
97 Interleaving String Python Medium
98 Validate Binary Search Tree Java Medium
100 Same Tree Java Easy
101 Symmetric Tree Java Easy
102 Binary Tree Level Order Traversal Java,Python Medium
103 Binary Tree Zigzag Level Order Traversal Python Medium
104 Maximum Depth of Binary Tree Java,Python Easy
105 Construct Binary Tree from Preorder and Inorder Traversal Python Medium
106 Construct Binary Tree from Inorder and Postorder Traversal Python Medium
107 Binary Tree Level Order Traversal II Java Medium
108 Convert Sorted Array to Binary Search Tree Python Easy
109 Convert Sorted List to Binary Search Tree Python Medium
110 Balanced Binary Tree Java Easy
111 Minimum Depth of Binary Tree Java Easy
112 Path Sum Java,Python Easy
113 Path Sum II Java,Python Medium
114 Flatten Binary Tree to Linked List Python Medium
116 Populating Next Right Pointers in Each Node Python Medium
117 Populating Next Right Pointers in Each Node II Python Medium
118 Pascal's Triangle Java Easy
119 Pascal's Triangle II Java Easy
120 Triangle Python Medium
121 Best Time to Buy and Sell Stock Python Easy
122 Best Time to Buy and Sell Stock II Python Medium
123 Best Time to Buy and Sell Stock III Python Hard
124 Binary Tree Maximum Path Sum Python Hard
125 Valid Palindrome Java Easy
126 Word Ladder II Python Hard
127 Word Ladder Java,Python Hard
128 Longest Consecutive Sequence Python Medium
129 Sum Root to Leaf Numbers Java Medium
130 Surrounded Regions Python Medium
131 Palindrome Partitioning Python Medium
132 Palindrome Partitioning II Python Hard
133 Clone Graph Python Medium
134 Gas Station Python Medium
135 Candy Python Hard
136 Single Number Java Easy
137 Single Number II Java Medium
138 Copy List with Random Pointer Java Medium
139 Word Break Java Medium
140 Word Break II Python Hard
141 Linked List Cycle Java Easy
142 Linked List Cycle II Java Medium
143 Reorder List Python Medium
144 Binary Tree Preorder Traversal Python Easy
145 Binary Tree Postorder Traversal Python Easy
146 LRU Cache Python Medium
147 Insertion Sort List Python Medium
148 Sort List Python Medium
149 Max Points on a Line Java Hard
150 Evaluate Reverse Polish Notation Python Medium
151 Reverse Words in a String Python Medium
152 Maximum Product Subarray Python Medium
153 Find Minimum in Rotated Sorted Array Python Medium
155 Min Stack Java,Python Medium
157 Read N Characters Given Read4 Python Easy
158 Read N Characters Given read4 II - Call Multiple Times Python Hard
159 Longest Substring with At Most Two Distinct Characters Python Medium
160 Intersection of Two Linked Lists Java,Python Easy
161 One Edit Distance Python Medium
162 Find Peak Element Java,Python Medium
163 Missing Ranges Python Easy
164 Maximum Gap Python Hard
165 Compare Version Numbers Java,Python Medium
166 Fraction to Recurring Decimal Python Medium
167 Two Sum II - Input Array Is Sorted Python Medium
168 Excel Sheet Column Title Python Easy
169 Majority Element Java,Python Easy
171 Excel Sheet Column Number Python Easy
172 Factorial Trailing Zeroes Python Medium
173 Binary Search Tree Iterator Python Medium
174 Dungeon Game Python Hard
175 Combine Two Tables SQL Easy
176 Second Highest Salary SQL Medium
177 Nth Highest Salary SQL Medium
178 Rank Scores SQL Medium
179 Largest Number Python Medium
180 Consecutive Numbers SQL Medium
181 Employees Earning More Than Their Managers SQL Easy
182 Duplicate Emails SQL Easy
183 Customers Who Never Order SQL Easy
184 Department Highest Salary SQL Medium
185 Department Top Three Salaries SQL Hard
187 Repeated DNA Sequences Java,Python Medium
188 Best Time to Buy and Sell Stock IV Python Hard
189 Rotate Array Java,Python Medium
190 Reverse Bits Java,Python Easy
191 Number of 1 Bits Java,Python Easy
192 Word Frequency Shell Medium
193 Valid Phone Numbers Shell Easy
194 Transpose File Shell Medium
195 Tenth Line Shell Easy
196 Delete Duplicate Emails SQL Easy
197 Rising Temperature SQL Easy
198 House Robber Java,Python Medium
199 Binary Tree Right Side View Python Medium
200 Number of Islands Python Medium
201 Bitwise AND of Numbers Range Python Medium
202 Happy Number Java Easy
203 Remove Linked List Elements Java,Python Easy
204 Count Primes Python Medium
205 Isomorphic Strings Java,Python Easy
206 Reverse Linked List Java,Python Easy
207 Course Schedule Python Medium
208 Implement Trie (Prefix Tree) Python Medium
209 Minimum Size Subarray Sum Python Medium
210 Course Schedule II Python Medium
211 Design Add and Search Words Data Structure Python Medium
212 Word Search II Python Hard
213 House Robber II Python Medium
215 Kth Largest Element in an Array Python Medium
216 Combination Sum III Python Medium
217 Contains Duplicate Java,Python Easy
218 The Skyline Problem Python Hard
219 Contains Duplicate II Java,Python Easy
220 Contains Duplicate III Python Hard
221 Maximal Square Python Medium
222 Count Complete Tree Nodes Python Medium
223 Rectangle Area Python Medium
224 Basic Calculator Python Hard
225 Implement Stack using Queues Python Easy
226 Invert Binary Tree Java,Python Easy
227 Basic Calculator II Python Medium
228 Summary Ranges Java,Python Easy
229 Majority Element II Java,Python Medium
230 Kth Smallest Element in a BST Python Medium
231 Power of Two Python Easy
232 Implement Queue using Stacks Python Easy
233 Number of Digit One C++,Python Hard
234 Palindrome Linked List Java,Python Easy
235 Lowest Common Ancestor of a Binary Search Tree Java,Python Medium
236 Lowest Common Ancestor of a Binary Tree Python Medium
237 Delete Node in a Linked List C++,Python Medium
238 Product of Array Except Self Python Medium
239 Sliding Window Maximum Python Hard
240 Search a 2D Matrix II Python Medium
241 Different Ways to Add Parentheses Python Medium
242 Valid Anagram Java Easy
246 Strobogrammatic Number Python Easy
247 Strobogrammatic Number II Python Medium
249 Group Shifted Strings Python Medium
251 Flatten 2D Vector Python Medium
252 Meeting Rooms Python Easy
253 Meeting Rooms II Python Medium
257 Binary Tree Paths Java Easy
258 Add Digits C++ Easy
260 Single Number III Java Medium
262 Trips and Users SQL Hard
263 Ugly Number Java Easy
264 Ugly Number II Java Medium
268 Missing Number Java Easy
269 Alien Dictionary Python Hard
270 Closest Binary Search Tree Value Python Easy
271 Encode and Decode Strings Python Medium
273 Integer to English Words Java Hard
274 H-Index Java Medium
275 H-Index II Python Medium
277 Find the Celebrity Python Medium
278 First Bad Version Python Easy
279 Perfect Squares Java Medium
282 Expression Add Operators Python Hard
283 Move Zeroes C++ Easy
284 Peeking Iterator Java Medium
285 Inorder Successor in BST Python Medium
286 Walls and Gates Python Medium
287 Find the Duplicate Number Java,Python Medium
289 Game of Life Python Medium
290 Word Pattern Java Easy
292 Nim Game Java,C++ Easy
295 Find Median from Data Stream Java Hard
297 Serialize and Deserialize Binary Tree Python Hard
299 Bulls and Cows Java Medium
300 Longest Increasing Subsequence Java Medium
301 Remove Invalid Parentheses Python Hard
303 Range Sum Query - Immutable Java Easy
304 Range Sum Query 2D - Immutable Java Medium
307 Range Sum Query - Mutable Python Medium
308 Range Sum Query 2D - Mutable Python Hard
309 Best Time to Buy and Sell Stock with Cooldown Python Medium
310 Minimum Height Trees Python Medium
311 Sparse Matrix Multiplication Python Medium
312 Burst Balloons Python Hard
313 Super Ugly Number Python Medium
314 Binary Tree Vertical Order Traversal Python Medium
315 Count of Smaller Numbers After Self Python Hard
316 Remove Duplicate Letters Python Medium
317 Shortest Distance from All Buildings Python Hard
318 Maximum Product of Word Lengths Python Medium
319 Bulb Switcher Python Medium
322 Coin Change Python Medium
323 Number of Connected Components in an Undirected Graph Python Medium
324 Wiggle Sort II Python Medium
325 Maximum Size Subarray Sum Equals k Python Medium
326 Power of Three Python Easy
328 Odd Even Linked List Java Medium
329 Longest Increasing Path in a Matrix Python Hard
330 Patching Array Java Hard
331 Verify Preorder Serialization of a Binary Tree Python Medium
332 Reconstruct Itinerary Python Hard
334 Increasing Triplet Subsequence Python Medium
336 Palindrome Pairs Python Hard
337 House Robber III Python Medium
338 Counting Bits Java Easy
340 Longest Substring with At Most K Distinct Characters Python Medium
341 Flatten Nested List Iterator Python Medium
342 Power of Four Python Easy
343 Integer Break Python Medium
344 Reverse String Java Easy
345 Reverse Vowels of a String Python Easy
347 Top K Frequent Elements Python Medium
348 Design Tic-Tac-Toe Python Medium
349 Intersection of Two Arrays Python Easy
350 Intersection of Two Arrays II Python Easy
351 Android Unlock Patterns Python Medium
353 Design Snake Game Python Medium
354 Russian Doll Envelopes Python Hard
355 Design Twitter Python Medium
357 Count Numbers with Unique Digits Python Medium
359 Logger Rate Limiter Python Easy
367 Valid Perfect Square C++ Easy
368 Largest Divisible Subset Python Medium
371 Sum of Two Integers Java Medium
374 Guess Number Higher or Lower Python Easy
376 Wiggle Subsequence Python Medium
377 Combination Sum IV Python Medium
378 Kth Smallest Element in a Sorted Matrix Python Medium
380 Insert Delete GetRandom O(1) Python Medium
382 Linked List Random Node Python Medium
383 Ransom Note Python Easy
384 Shuffle an Array Python Medium
387 First Unique Character in a String Python Easy
388 Longest Absolute File Path Python Medium
389 Find the Difference Python Easy
392 Is Subsequence Java,Python Easy
393 UTF-8 Validation Python Medium
394 Decode String Python Medium
398 Random Pick Index Python Medium
399 Evaluate Division Python Medium
401 Binary Watch Python Easy
402 Remove K Digits Python Medium
404 Sum of Left Leaves Python Easy
405 Convert a Number to Hexadecimal Python Easy
406 Queue Reconstruction by Height Python Medium
408 Valid Word Abbreviation Python Easy
409 Longest Palindrome Python Easy
410 Split Array Largest Sum Python Hard
412 Fizz Buzz Python Easy
413 Arithmetic Slices Python Medium
414 Third Maximum Number Python Easy
415 Add Strings Python Easy
416 Partition Equal Subset Sum Python Medium
417 Pacific Atlantic Water Flow Python Medium
419 Battleships in a Board Python Medium
421 Maximum XOR of Two Numbers in an Array Python Medium
422 Valid Word Square Python Easy
424 Longest Repeating Character Replacement Python Medium
425 Word Squares Python Hard
426 Convert Binary Search Tree to Sorted Doubly Linked List Python Medium
427 Construct Quad Tree Python Medium
429 N-ary Tree Level Order Traversal Python Medium
430 Flatten a Multilevel Doubly Linked List Python Medium
432 All O`one Data Structure Python Hard
433 Minimum Genetic Mutation Python Medium
434 Number of Segments in a String Python Easy
435 Non-overlapping Intervals Python Medium
437 Path Sum III Java Medium
438 Find All Anagrams in a String Java Medium
441 Arranging Coins Python Easy
442 Find All Duplicates in an Array Python Medium
443 String Compression Python Medium
445 Add Two Numbers II Python Medium
446 Arithmetic Slices II - Subsequence Python Hard
447 Number of Boomerangs Python Medium
448 Find All Numbers Disappeared in an Array Java Easy
449 Serialize and Deserialize BST Python Medium
451 Sort Characters By Frequency Python Medium
452 Minimum Number of Arrows to Burst Balloons Python Medium
453 Minimum Moves to Equal Array Elements Python Medium
454 4Sum II Python Medium
455 Assign Cookies Python Easy
456 132 Pattern Python Medium
458 Poor Pigs Python Hard
459 Repeated Substring Pattern Python Easy
460 LFU Cache Python Hard
461 Hamming Distance Java Easy
462 Minimum Moves to Equal Array Elements II Python Medium
463 Island Perimeter Python Easy
468 Validate IP Address Python Medium
473 Matchsticks to Square Python Medium
474 Ones and Zeroes Python Medium
476 Number Complement Python Easy
477 Total Hamming Distance Python Medium
478 Generate Random Point in a Circle Python Medium
482 License Key Formatting Python Easy
485 Max Consecutive Ones Java Easy
487 Max Consecutive Ones II Python Medium
489 Robot Room Cleaner Python Hard
491 Non-decreasing Subsequences Python Medium
492 Construct the Rectangle Python Easy
494 Target Sum Python Medium
495 Teemo Attacking Python Easy
496 Next Greater Element I Python Easy
498 Diagonal Traverse Python Medium
500 Keyboard Row Python Easy
501 Find Mode in Binary Search Tree Python Easy
503 Next Greater Element II Java Medium
504 Base 7 Python Easy
506 Relative Ranks Python Easy
507 Perfect Number Python Easy
509 Fibonacci Number Python Easy
511 Game Play Analysis I SQL Easy
516 Longest Palindromic Subsequence Python Medium
518 Coin Change II Python Medium
520 Detect Capital Python Easy
521 Longest Uncommon Subsequence I Python Easy
522 Longest Uncommon Subsequence II Python Medium
523 Continuous Subarray Sum Python Medium
524 Longest Word in Dictionary through Deleting Python Medium
525 Contiguous Array Python Medium
526 Beautiful Arrangement Python Medium
527 Word Abbreviation Python Hard
528 Random Pick with Weight Python Medium
530 Minimum Absolute Difference in BST Python Easy
532 K-diff Pairs in an Array Python Medium
535 Encode and Decode TinyURL Python Medium
536 Construct Binary Tree from String Python Medium
537 Complex Number Multiplication Python Medium
538 Convert BST to Greater Tree Java Medium
539 Minimum Time Difference Python Medium
540 Single Element in a Sorted Array Python Medium
541 Reverse String II Python Easy
543 Diameter of Binary Tree Java,Python Easy
547 Number of Provinces Python Medium
551 Student Attendance Record I Python Easy
554 Brick Wall Python Medium
556 Next Greater Element III Python Medium
557 Reverse Words in a String III Python Easy
558 Logical OR of Two Binary Grids Represented as Quad-Trees Python Medium
559 Maximum Depth of N-ary Tree Python Easy
560 Subarray Sum Equals K Java Medium
561 Array Partition Python Easy
563 Binary Tree Tilt Python Easy
565 Array Nesting Python Medium
566 Reshape the Matrix Python Easy
567 Permutation in String Python Medium
572 Subtree of Another Tree Java Easy
575 Distribute Candies Python Easy
576 Out of Boundary Paths Python Medium
581 Shortest Unsorted Continuous Subarray Java Medium
584 Find Customer Referee SQL Easy
586 Customer Placing the Largest Number of Orders SQL Easy
587 Erect the Fence Python Hard
589 N-ary Tree Preorder Traversal Python Easy
590 N-ary Tree Postorder Traversal Python Easy
594 Longest Harmonious Subsequence Python Easy
595 Big Countries SQL Easy
596 Classes More Than 5 Students SQL Easy
598 Range Addition II Python Easy
599 Minimum Index Sum of Two Lists Python Easy
601 Human Traffic of Stadium SQL Hard
605 Can Place Flowers Java Easy
606 Construct String from Binary Tree Python Easy
607 Sales Person SQL Easy
609 Find Duplicate File in System Python Medium
611 Valid Triangle Number Python Medium
617 Merge Two Binary Trees Java Easy
620 Not Boring Movies SQL Easy
621 Task Scheduler Python Medium
623 Add One Row to Tree Python Medium
626 Exchange Seats SQL Medium
627 Swap Salary SQL Easy
628 Maximum Product of Three Numbers Python Easy
629 K Inverse Pairs Array Python Hard
633 Sum of Square Numbers Python Medium
636 Exclusive Time of Functions Python Medium
637 Average of Levels in Binary Tree Python Easy
642 Design Search Autocomplete System Python Hard
643 Maximum Average Subarray I Python Easy
645 Set Mismatch Python Easy
647 Palindromic Substrings Python Medium
653 Two Sum IV - Input is a BST Python Easy
654 Maximum Binary Tree Python Medium
657 Robot Return to Origin Python Easy
658 Find K Closest Elements Python Medium
661 Image Smoother Python Easy
662 Maximum Width of Binary Tree Python Medium
665 Non-decreasing Array Python Medium
667 Beautiful Arrangement II Python Medium
668 Kth Smallest Number in Multiplication Table Python Hard
669 Trim a Binary Search Tree Python Medium
670 Maximum Swap Python Medium
671 Second Minimum Node In a Binary Tree Python Easy
674 Longest Continuous Increasing Subsequence Python Easy
678 Valid Parenthesis String Python Medium
680 Valid Palindrome II Python Easy
681 Next Closest Time Python Medium
682 Baseball Game Python Easy
686 Repeated String Match Python Medium
687 Longest Univalue Path Python Medium
690 Employee Importance Python Medium
692 Top K Frequent Words Python Medium
693 Binary Number with Alternating Bits Python Easy
695 Max Area of Island Python Medium
696 Count Binary Substrings Python Easy
697 Degree of an Array Python Easy
700 Search in a Binary Search Tree Python Easy
701 Insert into a Binary Search Tree Python Medium
703 Kth Largest Element in a Stream Python Easy
704 Binary Search Python Easy
705 Design HashSet Python Easy
706 Design HashMap Python Easy
707 Design Linked List Python Medium
708 Insert into a Sorted Circular Linked List Python Medium
709 To Lower Case Python Easy
714 Best Time to Buy and Sell Stock with Transaction Fee Python Medium
717 1-bit and 2-bit Characters Python Easy
720 Longest Word in Dictionary Python Medium
721 Accounts Merge Python Medium
724 Find Pivot Index Python Easy
725 Split Linked List in Parts Python Medium
728 Self Dividing Numbers Python Easy
729 My Calendar I Python Medium
731 My Calendar II Python Medium
732 My Calendar III Python Hard
733 Flood Fill Python Easy
734 Sentence Similarity Python Easy
735 Asteroid Collision Python Medium
738 Monotone Increasing Digits Python Medium
739 Daily Temperatures Python Medium
740 Delete and Earn Python Medium
743 Network Delay Time Python Medium
744 Find Smallest Letter Greater Than Target Python Easy
745 Prefix and Suffix Search Python Hard
746 Min Cost Climbing Stairs Python Easy
747 Largest Number At Least Twice of Others Python Easy
748 Shortest Completing Word Python Easy
752 Open the Lock Python Medium
753 Cracking the Safe Python Hard
760 Find Anagram Mappings Python Easy
762 Prime Number of Set Bits in Binary Representation Python Easy
763 Partition Labels Python Medium
764 Largest Plus Sign Python Medium
766 Toeplitz Matrix Python Easy
767 Reorganize String Python Medium
771 Jewels and Stones Python Easy
777 Swap Adjacent in LR String Python Medium
779 K-th Symbol in Grammar Python Medium
783 Minimum Distance Between BST Nodes Python Easy
784 Letter Case Permutation Python Medium
785 Is Graph Bipartite? Python Medium
787 Cheapest Flights Within K Stops Python Medium
788 Rotated Digits Python Medium
790 Domino and Tromino Tiling Python Medium
791 Custom Sort String Python Medium
792 Number of Matching Subsequences Python Medium
795 Number of Subarrays with Bounded Maximum Python Medium
796 Rotate String Python Easy
797 All Paths From Source to Target Python Medium
799 Champagne Tower Python Medium
801 Minimum Swaps To Make Sequences Increasing Python Hard
804 Unique Morse Code Words Python Easy
806 Number of Lines To Write String Python Easy
809 Expressive Words Python Medium
811 Subdomain Visit Count Python Medium
812 Largest Triangle Area Python Easy
814 Binary Tree Pruning Python Medium
816 Ambiguous Coordinates Python Medium
819 Most Common Word Python Easy
820 Short Encoding of Words Python Medium
821 Shortest Distance to a Character Python Easy
823 Binary Trees With Factors Python Medium
824 Goat Latin Python Easy
825 Friends Of Appropriate Ages Python Medium
827 Making A Large Island Python Hard
830 Positions of Large Groups Python Easy
832 Flipping an Image Java Easy
833 Find And Replace in String Python Medium
834 Sum of Distances in Tree Python Hard
836 Rectangle Overlap Python Easy
837 New 21 Game Python Medium
840 Magic Squares In Grid Python Medium
841 Keys and Rooms Python Medium
843 Guess the Word Python Hard
844 Backspace String Compare Python Easy
847 Shortest Path Visiting All Nodes Python Hard
848 Shifting Letters Python Medium
849 Maximize Distance to Closest Person Python Medium
852 Peak Index in a Mountain Array Python Medium
856 Score of Parentheses Python Medium
857 Minimum Cost to Hire K Workers Python Hard
858 Mirror Reflection Python Medium
859 Buddy Strings Python Easy
860 Lemonade Change Python Easy
863 All Nodes Distance K in Binary Tree Python Medium
865 Smallest Subtree with all the Deepest Nodes Python Medium
867 Transpose Matrix Python Easy
868 Binary Gap Python Easy
871 Minimum Number of Refueling Stops Python Hard
872 Leaf-Similar Trees Java Easy
874 Walking Robot Simulation Java Medium
875 Koko Eating Bananas Python Medium
876 Middle of the Linked List Python Easy
877 Stone Game Python Medium
880 Decoded String at Index Python Medium
881 Boats to Save People Python Medium
883 Projection Area of 3D Shapes Java Easy
884 Uncommon Words from Two Sentences Python Easy
885 Spiral Matrix III Python Medium
886 Possible Bipartition Python Medium
888 Fair Candy Swap Python Easy
890 Find and Replace Pattern Python Medium
892 Surface Area of 3D Shapes Python Easy
893 Groups of Special-Equivalent Strings Python Medium
894 All Possible Full Binary Trees Python Medium
895 Maximum Frequency Stack Python Hard
896 Monotonic Array Python Easy
897 Increasing Order Search Tree Python Easy
899 Orderly Queue Python Hard
900 RLE Iterator Python Medium
901 Online Stock Span Python Medium
904 Fruit Into Baskets Python Medium
905 Sort Array By Parity Python Easy
907 Sum of Subarray Minimums Python Medium
908 Smallest Range I Python Easy
914 X of a Kind in a Deck of Cards Python Easy
915 Partition Array into Disjoint Intervals Python Medium
916 Word Subsets Python Medium
917 Reverse Only Letters Python Easy
918 Maximum Sum Circular Subarray Python Medium
921 Minimum Add to Make Parentheses Valid Python Medium
922 Sort Array By Parity II Python Easy
925 Long Pressed Name Python Easy
929 Unique Email Addresses Python Easy
931 Minimum Falling Path Sum Python Medium
932 Beautiful Array Python Medium
933 Number of Recent Calls Python Easy
935 Knight Dialer Python Medium
938 Range Sum of BST Python Easy
939 Minimum Area Rectangle Python Medium
941 Valid Mountain Array Python Easy
942 DI String Match Python Easy
944 Delete Columns to Make Sorted Python Easy
946 Validate Stack Sequences Python Medium
947 Most Stones Removed with Same Row or Column Python Medium
948 Bag of Tokens Python Medium
949 Largest Time for Given Digits Python Medium
951 Flip Equivalent Binary Trees Python Medium
953 Verifying an Alien Dictionary Python Easy
958 Check Completeness of a Binary Tree Python Medium
961 N-Repeated Element in Size 2N Array Python Easy
962 Maximum Width Ramp Python Medium
963 Minimum Area Rectangle II Python Medium
965 Univalued Binary Tree Python Easy
966 Vowel Spellchecker Python Medium
967 Numbers With Same Consecutive Differences Python Medium
968 Binary Tree Cameras Python Hard
970 Powerful Integers Python Medium
973 K Closest Points to Origin Python Medium
975 Odd Even Jump Python Hard
976 Largest Perimeter Triangle Python Easy
977 Squares of a Sorted Array Python Easy
980 Unique Paths III Python Hard
981 Time Based Key-Value Store Python Medium
985 Sum of Even Numbers After Queries Python Medium
986 Interval List Intersections Python Medium
987 Vertical Order Traversal of a Binary Tree Python Hard
989 Add to Array-Form of Integer Python Easy
991 Broken Calculator Python Medium
993 Cousins in Binary Tree Python Easy
997 Find the Town Judge Python Easy
999 Available Captures for Rook Python Easy
1002 Find Common Characters Python Easy
1004 Max Consecutive Ones III Python Medium
1005 Maximize Sum Of Array After K Negations Python Easy
1007 Minimum Domino Rotations For Equal Row Python Medium
1008 Construct Binary Search Tree from Preorder Traversal Python Medium
1009 Complement of Base 10 Integer Python Easy
1010 Pairs of Songs With Total Durations Divisible by 60 Python Medium
1013 Partition Array Into Three Parts With Equal Sum Python Easy
1015 Smallest Integer Divisible by K Python Medium
1018 Binary Prefix Divisible By 5 Python Easy
1019 Next Greater Node In Linked List Python Medium
1021 Remove Outermost Parentheses Python Easy
1022 Sum of Root To Leaf Binary Numbers Python Easy
1025 Divisor Game Python Easy
1026 Maximum Difference Between Node and Ancestor Python Medium
1027 Longest Arithmetic Subsequence Python Medium
1029 Two City Scheduling Python Medium
1030 Matrix Cells in Distance Order Python Easy
1032 Stream of Characters Python Hard
1035 Uncrossed Lines Python Medium
1037 Valid Boomerang Python Easy
1044 Longest Duplicate Substring Python Hard
1046 Last Stone Weight Python Easy
1047 Remove All Adjacent Duplicates In String Python Easy
1048 Longest String Chain Python Medium
1049 Last Stone Weight II Python Medium
1050 Actors and Directors Who Cooperated At Least Three Times SQL Easy
1051 Height Checker Python Easy
1055 Shortest Way to Form String Python Medium
1057 Campus Bikes Python Medium
1064 Fixed Point Python Easy
1066 Campus Bikes II Python Medium
1071 Greatest Common Divisor of Strings Python Easy
1074 Number of Submatrices That Sum to Target Python Hard
1078 Occurrences After Bigram Python Easy
1081 Smallest Subsequence of Distinct Characters Python Medium
1084 Sales Analysis III SQL Easy
1089 Duplicate Zeros Python Easy
1091 Shortest Path in Binary Matrix Python Medium
1094 Car Pooling Python Medium
1103 Distribute Candies to People Python Easy
1108 Defanging an IP Address Python Easy
1114 Print in Order Python Easy
1122 Relative Sort Array Python Easy
1123 Lowest Common Ancestor of Deepest Leaves Python Medium
1128 Number of Equivalent Domino Pairs Python Easy
1137 N-th Tribonacci Number Python Easy
1141 User Activity for the Past 30 Days I SQL Easy
1143 Longest Common Subsequence Python Medium
1148 Article Views I SQL Easy
1154 Day of the Year Python Easy
1155 Number of Dice Rolls With Target Sum Python Medium
1160 Find Words That Can Be Formed by Characters Python Easy
1178 Number of Valid Words for Each Puzzle Python Hard
1179 Reformat Department Table Easy
1184 Distance Between Bus Stops Python Easy
1185 Day of the Week Python Easy
1189 Maximum Number of Balloons Python Easy
1192 Critical Connections in a Network Python Hard
1200 Minimum Absolute Difference Python Easy
1202 Smallest String With Swaps Python Medium
1207 Unique Number of Occurrences Python Easy
1209 Remove All Adjacent Duplicates in String II Python Medium
1217 Minimum Cost to Move Chips to The Same Position Python Easy
1220 Count Vowels Permutation Python Hard
1221 Split a String in Balanced Strings Python Easy
1232 Check If It Is a Straight Line Python Easy
1235 Maximum Profit in Job Scheduling Python Hard
1249 Minimum Remove to Make Valid Parentheses Python Medium
1252 Cells with Odd Values in a Matrix Python Easy
1260 Shift 2D Grid Python Easy
1266 Minimum Time Visiting All Points Python Easy
1268 Search Suggestions System Python Medium
1277 Count Square Submatrices with All Ones Python Medium
1283 Find the Smallest Divisor Given a Threshold Python Medium
1286 Iterator for Combination Python Medium
1288 Remove Covered Intervals Python Medium
1290 Convert Binary Number in a Linked List to Integer Python Easy
1302 Deepest Leaves Sum Python Medium
1306 Jump Game III Python Medium
1323 Maximum 69 Number Python Easy
1332 Remove Palindromic Subsequences Python Easy
1337 The K Weakest Rows in a Matrix Python Easy
1338 Reduce Array Size to The Half Python Medium
1339 Maximum Product of Splitted Binary Tree Python Medium
1342 Number of Steps to Reduce a Number to Zero Python Easy
1344 Angle Between Hands of a Clock Python Medium
1345 Jump Game IV Python Hard
1359 Count All Valid Pickup and Delivery Options Python Hard
1379 Find a Corresponding Node of a Binary Tree in a Clone of That Tree Python Easy
1383 Maximum Performance of a Team Python Hard
1396 Design Underground System Python Medium
1413 Minimum Value to Get Positive Step by Step Sum Python Easy
1426 Counting Elements Python Easy
1427 Perform String Shifts Python Easy
1428 Leftmost Column with at Least a One Python Medium
1429 First Unique Number Python Medium
1430 Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree Python Medium
1446 Consecutive Characters Python Easy
1448 Count Good Nodes in Binary Tree Python Medium
1457 Pseudo-Palindromic Paths in a Binary Tree Python Medium
1461 Check If a String Contains All Binary Codes of Size K Python Medium
1465 Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts Python Medium
1473 Paint House III Python Hard
1480 Running Sum of 1d Array Python Easy
1492 The kth Factor of n Python Medium
1510 Stone Game IV Python Hard
1539 Kth Missing Positive Number Python Easy
1544 Make The String Great Python Easy
1551 Minimum Operations to Make Array Equal Python Medium
1578 Minimum Time to Make Rope Colorful Python Medium
1629 Slowest Key Python Easy
1631 Path With Minimum Effort Python Medium
1640 Check Array Formation Through Concatenation Python Easy
1641 Count Sorted Vowel Strings Python Medium
1642 Furthest Building You Can Reach Python Medium
1657 Determine if Two Strings Are Close Python Medium
1662 Check If Two String Arrays are Equivalent Python Easy
1663 Smallest String With A Given Numeric Value Python Medium
1675 Minimize Deviation in Array Python Hard
1679 Max Number of K-Sum Pairs Python Medium
1689 Partitioning Into Minimum Number Of Deci-Binary Numbers Python Medium
1690 Stone Game VII Python Medium
1695 Maximum Erasure Value Python Medium
1696 Jump Game VI Python Medium
1704 Determine if String Halves Are Alike Python Easy
1706 Where Will the Ball Fall Python Medium
1710 Maximum Units on a Truck Python Easy
1721 Swapping Nodes in a Linked List Python Medium
1834 Single-Threaded CPU Python Medium
1926 Nearest Exit from Entrance in Maze Python Medium
1962 Remove Stones to Minimize the Total Python Medium
1971 Find if Path Exists in Graph Python Easy
1996 The Number of Weak Characters in the Game Python Medium
2007 Find Original Array From Doubled Array Python Medium
2154 Keep Multiplying Found Values by Two Python Easy
2160 Minimum Sum of Four Digit Number After Splitting Digits Python Easy
2164 Sort Even and Odd Indices Independently Python Easy
2169 Count Operations to Obtain Zero Python Easy
2176 Count Equal and Divisible Pairs in an Array Python Easy
2180 Count Integers With Even Digit Sum Python Easy
2185 Counting Words With a Given Prefix Python Easy
2225 Find Players With Zero or One Losses Python Medium
2256 Minimum Average Difference Python Medium
2279 Maximum Bags With Full Capacity of Rocks Python Medium
2389 Longest Subsequence With Limited Sum Python Easy

Features

  • Contains a lot of interview questions and still constantly adding!
  • Many languages are used for problems -- you can choose what you want!

Quick Start

Clone it. Have a look at the solutions or some particular question and get inpired!

Contribution Guide

You can choose any problem in LeetCode and bring your solution here. However, notice the folder structure of current repo

--questions          # root folder for questions
  --3sum             # named after the question title slug
    --Solution.java  # actual code for the solution. the problem description and maybe even explanation
                     #   for the solution are in the form of comments
  1. Fork the repository.
  2. Solve the problem in LeetCode.
  3. Create the solution file in the correct directory and add the link to README table.
  4. Create pull request.
  5. After review and discussions, the patch will be merged!

Question and Help

You are welcome to use Issue Trackers in the repository to bring up any questions!

License

MIT license. You are free to contribute or hack!