Skip to content

Solutions to Common Algorithms and Data Structures Problems in Multiple Languages

License

Notifications You must be signed in to change notification settings

soumasish/leetcodely

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solutions to Leetcode Problems in Multiple Languages

If you wish to contribute, a big thanks, feel free to send me a PR. If you wish to contribute in a different language that's great too, just update the index accordingly. There's also a list (non-leetcode) of questions that, I believe, shouldn't ever make it to a coding interview, but I've still solved them since I faced them multiple times.

Contents

# Problem Python Java C++ Javascript SQL
1 Two Sum x x x
2 Add Two Numbers x x x
3 Longest Substring without Repeating Characters x x x
4 Median of Two Sorted Arrays x
5 Longest Palindromic Substring x x
6 Zig Zag Conversion x
7 Reverse Integer x x
8 String to Integer x
9 Palindrome Number x
10 Regular Expression Matching x
11 Container With Most Water x
13 Roman to Integer x
15 3Sum x
17 Letter Combination of Phone Number x
20 Valid Parantheses x
21 Merge Two Sorted Lists x
22 Generate Paratheses x
23 Merge K Sorted Lists x
24 Swap Nodes in Pairs x
26 Remove Duplicates x
31 Next Permutation x
33 Search in a Rotated Array x x
34 Find First and Last Position of Element in Sorted Array x
37 Sudoku Solver x
42 Trapping Rain Water x
44 Wildcard Matching x
46 Permutations x
48 Rotate Image x
50 Pow(x,n) x
51 N-Queens x
53 Maximum Subarray Sum x
54 Spiral Matrix x
56 Merge Intervals x
57 Insert Interval x
66 Plus One x
67 Add Binary x
68 Text Justification x
69 Sqrt(x) x
70 Climbing Stairs x
75 Sort Colors x
76 Min Window Substring x
78 Subsets x
84 Largest Rectangle in Histogram x
85 Maximal Rectangle x
91 Decode Ways x
94 Binary Tree Inorder Traversal x
95 Unique Binary Search Trees -II x
98 Validate Binary Search Tree x
100 Same Tree x
101 Symmetric Tree x
102 Binary Tree Level Order Traversal x
107 Binary Tree Level Order Traversal II x
103 Binary Tree Zig Zag Level Order Traversal x
104 Maximum Depth of Binary Tree x
114 Flatten a Binary Tree to Linked List x
116 Populating Next Right Pointers x
117 Populating Next Right Pointers in Each Node II x
118 Pascal's Triangle x
121 Best Time to Buy & Sell Stock x
125 Valid Palindrome x
127 Word Ladder x
128 Longest Consecutive Sequence x
133 Clone Graph x
138 Copy List of Random Pointer x
139 Word Break x x
144 Binary Tree Preorder Traversal x
145 Binary Tree Postorder Traversal x
146 LRU Cache x
150 Reverse Polish Notation x
152 Maximum Product Subarray x
155 Min Stack x
156 Binary Tree Upside Down x
157 Read N Characters Given Read4 x
158 Read N Characters Given Read4 II - Call multiple times x
159 Longest Substring with At Most Two Distinct Characters x
161 One Edit Distance x
162 Find Peak Element x
163 Missing Ranges x
165 Compare Versions x
168 Excel Sheet Column Title x
170 Two Sum III - Data structure design x
171 Excel Sheet Column Number x
173 Binary Search Tree Iterator x
175 Combine Two Tables x
177 Nth Highest Salary x
180 Consecutive Numbers x
181 Employees Earning More Than Their Managers x
182 Duplicate Emails x
183 Customers Who Never Order x
187 Repeated DNA Sequences x
196 Delete Duplicate Emails x
197 Rising Temperature x
198 House Robber x
199 Binary Tree Right Side View x
200 Number of Islands x x
205 Isomorphic Strings x x
208 Implement Trie x
210 Course Schedule II x
211 Design Add and Search Word Data Structure x
212 Word Search II x
215 Kth Largest Element in an Array x
221 Maximal Square x
231 Power of Two x
236 Lowest Common Ancestor of a Binary Tree x
237 Delete Node in a Linked List x
238 Product of Array Except Self x
239 Sliding Window Maximum x
240 Search a 2D matrix x
243 Shortest Word Distance x
244 Shortest Word Distance II x
245 Shortest Word Distance III x
246 Strobogrammatic Number x
246 Strobogrammatic Number II x
251 Flatten 2D Vector x
252 Meeting Rooms x
253 Meeting Rooms II x
254 Factor Combinations x
256 Paint House x
257 Binary Tree Paths x
259 3Sum Samller x
266 Palindrome Permutation x
270 Closest Binary Search Tree Value x
271 Encode & Decode Strings x
273 Integer to English Word x
274 H Index x
276 Paint Fence x
277 Find Celebrity x
278 First Bad Version x
281 Zig Zag Interator x
283 Move Zeroes x
284 Peeking Interator x
285 Inorder Successor x
286 Walls and Gates x
289 Game of Life x
290 Word Pattern x
295 Find Median from Data Stream x
297 Serialize and Deserialize Binary Tree x
298 Binary Tree Longest Consecutive Sequence x
301 Remove Invalid Parentheses x
312 Burst Balloons x
314 Binary Tree Vertical Order Traversal x
316 Remove Duplicate Letters x
325 Maximum Size Subarray Sum Equals K x
326 Power of Three x
339 Nested List Weight Sum x
340 Longest Substring with At Most K Distinct Characters x
341 Flatten Nested List Iterator x
345 Reverse Vowels of a String x
346 Moving Average of a Data Stream x
348 Design Tic Tac Toe x
350 Intersection of Two Arrays II x
357 Count Number of Unique Digits x
359 Logger Rate Limiter x
361 Bomb Enemy x
364 Nested List Weighted Sum II x
366 Find Leaves of a Binary Tree x
367 Valid Perfect Square x
373 Find K Pairs with Smallest Sums x
380 Insert Delete GetRandom O(1) x
383 Ransom Note x
387 First Unique Character in a String x
388 Longest Absolute File Path x
392 Is Subsequence x
404 Sum of Left Leaves x
416 Partition Equal Subset Sum x
418 Sentence Screen Fitting x
419 Battleships in a Board x
429 N-ary Tree Level Order Traversal x
433 Minimum Genetic Mutation x
437 Path Sum III x
438 Find All Anagrams in a String x
447 Number of Boomerangs x
449 Serialize & Deserialize a BST x
450 Delete a Node in a BST x
451 Sort Characters by Frequency x
459 Repeated Substring Pattern x
460 LFU Cache x
464 Can I Win x
482 License Key Formatting x
485 Maximum Consecutive Ones x
501 Find Mode in Binary Search Tree x
508 Most Frequent Subtree sum x
509 Fibonacci Number x
510 In Order Successor II x
511 Game Play Analysis I x
512 Game Play Analysis II x
515 Largest Value in Each Tree Row x
516 Longest Palindromic Subsequence x
523 Continuous Subarray Sum x
530 Minimum Absolute Difference x x
532 K-diff Pairs in an Array x x
534 Game Play Analysis III x
535 Encode and Decode TinyURL x
537 Complex Number Multiplication x
540 Single Element in a Sorted Array x
550 Game Play Analysis IV x
574 Winning Candidate x
589 N-ary Tree Preorder Traversal x
590 N-ary Tree Postorder Traversal x
595 Big Countries x
597 Friend Requests I: Overall Acceptance Rate x
605 Can Place Flowers x
606 Construct String from Binary Tree x
616 Add Bold Tags x
617 Merge Two Binary Trees x
619 Biggest Single Number x
633 Sum of Square numbers x
636 Exclusive Time Functions x
637 Average of Levels in Binary Tree x
640 Solve the Equation x
645 Set Mismatch x
646 Maximum Length of Pair Chain x
647 Palindromic Substrings x
653 Two Sum IV - Input is a BST x
654 Maximum Binary Tree x
681 Next Closest Time x
682 Baseball Game x
690 Employee Importance x
702 Search In a Sorted Array of Unknown Size x x
708 Insert into a sorted circular Linked List x
716 Max Stack x
720 Longest Word in Dictionary x
733 Flood Fill x
734 Sentence Similarity x
735 Asteroid Collision x
737 Sentence Similarity II x
746 Min Cost Climbing Stairs x
776 Split BST x
780 Reaching Points x [x](x
783 Minimum Distance Between BST Nodes x x
817 Linked List Components x
824 Goat Latin x
830 Positions of Large Groups x
832 Flipping An Image x
839 Similar String Groups x x
840 Magic Squares in a Grid x
841 Keys and Rooms x
844 Backspace String Compare x
849 Maximize Distance to Closest Person x
852 Peak Index in a Mountain Array x
853 Car Fleet x
854 K Similar Strings x
859 Buddy Strings x
864 Shortest Path to All Keys x
865 Smallest Subtree with all the Deepest Nodes x
896 Monotonic Array x
921 Minimum Add to Make Paranthesis Valid x x
924 Minimize Malware Spread x
937 Reorder Log Files x
938 Range Sum of BST x
953 Verify and Alien Dictionary x
958 Check Completeness of Binary Tree x x
959 Regions Cut By Slashes x
971 Flip Binary Tree To Match Preorder Traversal x
973 K Closest Point to Origin x
987 Vertical Order Traversal of a Binary Tree x
990 Satisfiability of Equality Equations x
994 Rotting Oranges x
997 Find the Town Judge x
1004 Maximum Consecutive Ones III x
1008 Construct Binary Search Tree From Preorder Traversal x
1021 Remove Outermost Parantheses x
1022 Sum of Root to Leaf Numbers x
1026 Maximum Difference Between Node and Ancestor x
1027 Longest Arithmetic Sequence x
1045 Customers Who Bought All Products x
1050 Actors and Directors Who Cooperated At Least Three Times x
1075 Project Employees I x
1112 Highest Grade For Each Student x
1114 Print in Order x
1115 Print FooBar Alternately x
1137 N-th Tribonacci Number x
1145 Binary Tree Coloring Game x x
1165 Single Row Keyboard x
1188 Bounded Blocking Queue x
1241 Number of Comments per post x
1303 Find the Team Size x
1322 Ads Performance x
1667 Fix Names in a Table x
1757 Recyclable and Low Fat Products x

About

Solutions to Common Algorithms and Data Structures Problems in Multiple Languages

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •