Skip to content

🏋️ Python / Modern C++ Solutions of All 3049 LeetCode Problems (Weekly Update)

License

Notifications You must be signed in to change notification settings

rhshriva/LeetCode-Solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode

Up to date, there are total 154 problems on LeetCode Online Judge. The number of problems is increasing recently. Here is the classification of all 154 problems. I'll keep updating for full summary and better solutions. Stay tuned for updates.



##Bit Manipulation

Problem Solution Time Space Difficulty Notes

##Array

Problem Solution Time Space Difficulty Notes
3 Sum 3sum.py O(n^2) O(1) Medium
3 Sum Closest 3sum-closest.py O(n^2) O(1) Medium
4 Sum 4sum.py O(n^2) ~ O(n^4) O(n^2) Medium
Best Time to Buy and Sell Stock best-time-to-buy-and-sell-stock.py O(n) O(1) Medium
First Missing Positive first-missing-positive.py O(n) O(1) Hard

##String

Problem Solution Time Space Difficulty Notes
Add Binary add-binary.py O(n) O(1) Easy
Anagrams anagrams.py O(n) O(n) Medium
Count and Say count-and-say.py O(n^2) O(n) Easy

##Linked List

Problem Solution Time Space Difficulty Notes
Add Two Numbers add-two-numbers.py O(n) O(1) Medium
Copy List with Random Pointer copy-list-with-random-pointer.py O(n) O(1) Hard

##Stack

Problem Solution Time Space Difficulty Notes
Evaluate Reverse Polish Notation evaluate-reverse-polish-notation.py O(n) O(n) Medium

##Heap

Problem Solution Time Space Difficulty Notes

##Tree

Problem Solution Time Space Difficulty Notes
Binary Tree Preorder Traversal binary-tree-preorder-traversal.py O(n) O(n) Medium
Binary Tree Inorder Traversal binary-tree-inorder-traversal.py O(n) O(n) Medium
Binary Tree Postorder Traversal binary-tree-postorder-traversal.py O(n) O(n) Hard

---

##Graph

Problem Solution Time Space Difficulty Notes

##Hash Table

Problem Solution Time Space Difficulty Notes

##Data Structure

Problem Solution Time Space Difficulty Notes

##Math

Problem Solution Time Space Difficulty Notes
Gray Code gray-code.py O(2^n) O(1) Medium

##Sort

Problem Solution Time Space Difficulty Notes

##Divide and Conquer

Problem Solution Time Space Difficulty Notes
Construct Binary Tree from Inorder and Postorder Traversal construct-binary-tree-from-inorder-and-postorder-traversal.py O(n) O(n) Medium
Construct Binary Tree from Preorder and Inorder Traversal construct-binary-tree-from-preorder-and-inorder-traversal.py O(n) O(n) Medium
Convert Sorted Array to Binary Search Tree convert-sorted-array-to-binary-search-tree.py O(n) O(logn) Medium
Convert Sorted List to Binary Search Tree convert-sorted-list-to-binary-search-tree.py O(n) O(logn) Medium
Flatten Binary Tree to Linked List flatten-binary-tree-to-linked-list.py O(n) O(logn) Medium

##Binary Search

Problem Solution Time Space Difficulty Notes
Search in Rotated Sorted Array find-minimum-in-rotated-sorted-array.py O(logn) O(1) Medium
Search in Rotated Sorted Array II find-minimum-in-rotated-sorted-array-ii.py O(logn) ~ O(n) O(1) Hard

##Breadth-First Search

Problem Solution Time Space Difficulty Notes
Binary Tree Level Order Traversal binary-tree-level-order-traversal.py O(n) O(n) Easy
Binary Tree Level Order Traversal II binary-tree-level-order-traversal-ii.py O(n) O(n) Easy
Binary Tree Zigzag Level Order Traversal binary-tree-zigzag-level-order-traversal.py O(n) O(n) Medium
Clone Graph clone-graph.py O(n) O(n) Medium

##Depth-First Search

Problem Solution Time Space Difficulty Notes
Balanced Binary Tree balanced-binary-tree.py O(n) O(logn) Easy
Binary Tree Maximum Path Sum binary-tree-maximum-path-sum.py O(n) O(logn) Hard
Combination Sum combination-sum.py O(n) O(n) Medium
Combination Sum II combination-sum-ii.py O(n) O(n) Medium
Combinations combinations.py O(n!) O(n) Medium
Generate Parentheses generate-parentheses.py O(4^n / n^(3/2)) O(n) Medium

##Dynamic Programming

Problem Solution Time Space Difficulty Notes
Best Time to Buy and Sell Stock III best-time-to-buy-and-sell-stock-iii.py O(n) O(1) Hard
Climbing Stairs climbing-stairs.py O(n) O(1) Easy
Decode Ways decode-ways.py O(n) O(1) Medium
Distinct Subsequences distinct-subsequences.py O(n^2) O(n) Medium
Edit Distance edit-distance.py O(n * m) O(n + m) Medium

##Backtracking

Problem Solution Time Space Difficulty Notes

##Greedy

Problem Solution Time Space Difficulty Notes
Best Time to Buy and Sell Stock II best-time-to-buy-and-sell-stock-ii.py O(n) O(1) Medium
Candy candy.py O(n) O(n) Hard
Container With Most Water container-with-most-water.py O(n) O(1) Medium
Gas Station gas-station.py O(n) O(1) Medium

About

🏋️ Python / Modern C++ Solutions of All 3049 LeetCode Problems (Weekly Update)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 54.1%
  • Python 45.3%
  • TypeScript 0.5%
  • Java 0.1%
  • Go 0.0%
  • Shell 0.0%