Got stuck in a LeetCode question? This repository will help you by providing approach of solving the problems from LeetCode platform.
Contributors helped us in providing these Awesome solutions.
If you want to contribute, please create a Pull Request. If you are new to Github please check pull request procedure ---> PR process
Check out ---> Sample PR
- There are new LeetCode questions every week. I'll keep updating for full summary and better solutions.
- For more challenging problem solutions, you can also see our HackerRank-Solutions, ProjectEuler repositories.
- Hope you enjoy the journey of learning data structures and algorithms.
- Notes: "🔒" means your subscription of LeetCode premium membership is required for reading the question.
Check out -> Learning Resources
- Bit Manipulation
- Array
- String
- Linked List
- Stack
- Queue
- Heap
- Tree
- Hash Table
- Math
- Two Pointers
- Sort
- Recursion
- Binary Search
- Binary Search Tree
- Breadth-First Search
- Depth-First Search
- Backtracking
- Dynamic Programming
- Greedy
- Graph
- Geometry
- Simulation
- Design
- Concurrency
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
0136 | Single Number | Java Python |
O(n) | O(1) | Easy | Using XOR | |
0260 | Single Number III | Python | O(n) | O(1) | Medium | ||
0520 | Detect Capital Use | Python | O(n) | O(1) | Easy |
# | Title | Solution | Time | Space | Difficulty | Note | Video Explaination |
---|---|---|---|---|---|---|---|
56 | Merge Intervals | Python | O(nlogn) | O(n) | Medium | Intervals | |
268 | Missing Number | Java | O(n) | O(1) | Easy | Array | Tutorial |
697 | Degree of an Array | Java | O(n) | O(n) | Easy | Array | |
1089 | Duplicate Zeroes | JavaScript | O(n) | O(n) | Easy | Array | |
1502 | Can Make Arithmetic Progression From Sequence | Java | O(n) | O(1) | Easy | Array | |
122 | Best Time to buy and sell Stock II | Python | O(N) | O(1) | Medium | Stocks | |
119 | Pascal's Triangle II | Python | O(N^2) | O(K) | Easy | ||
1480 | Running Sum of 1d Array | Java | O(N) | O(N) | Easy | Simple sum | |
42 | Trapping Rain Water | Python | O(N^2) | O(N) | Hard | Array | |
11 | Container with Most Water | Python | O(N) | O(N) | Medium | Array Two Pointers | |
1534 | Count Good Triplets | Python | O(N^3) | O(1) | Easy |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
383 | Ransom Note | Java | O(1) | O(n) | Easy | Character Count | |
387 | First Unique Character in a String | Java | O(n) | O(1) | Easy | Character Count | |
151 | Reverse Words in a String | Java | O(1) | O(n) | Medium | ||
520 | Detect Capital Use | Java | O(n) | O(1) | Easy | ||
1221 | Split a String in Balanced Strings | Python | O(n) | O(1) | Easy |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
002 | Add Two Numbers | Java | O(n) | O(n) | Medium | Math | |
19 | Remove Nth Node From End of List | Java | O(n) | O(1) | Medium | Two pointers | |
109 | Convert Sorted List to Binary Search Tree | Java | O(n) | O(n) | Medium | LinkedList | |
141 | Linked List Cycle | Java | O(n) | O(1) | Easy | Slow-Fast Pointers | |
146 | LRU Cache | C++ | O(1) | O(k) | Medium | Hash Map | |
186 | Middle of the Linked List | Java | O(n) | O(1) | Easy | Two pointers |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
020 | Valid Parentheses | Python | O(n) | O(n) | Easy | Stack | |
150 | Evaluate Reverse Polish Notation | Python | O(n) | O(1) | Medium | Stack |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
094 | Binary Tree Inorder Traversal | Java | O(n) | O(logn) | Medium | Binary Tree, Stack, HashTable | |
100 | Same Tree | Python | O(n) | O(n) | Easy | Tree, Depth-first Search | |
101 | Symmetric Tree | Java Python |
O(n) | O(n) | Easy | Tree, Breadth-first Search, Depth-first Search | |
144 | Binary Tree Preorder Traversal | Java | O(n) | O(logn) | Medium | Binary Tree, Stack | |
145 | Binary Tree Postorder Traversal | Java | O(n) | O(logn) | Hard | Binary Tree, Stack | |
103 | ZigZag Level Order | JavaScript | O(n) | O(n) | Medium | Binary Tree | |
129 | Sum Root to Leaf Numbers | Java | O(n) | O(logn) | Medium | Binary Tree, Depth First Search | |
307 | Range Sum Query - Mutable | Java | O(logn) | O(n) | Medium | Segment Tree | |
919 | Complete Binary Tree Inserter | Java | O(n) | O(n) | Medium | Tree | |
124 | Binary Tree Maximum Path Sum | C++ | O(n) | O(n) | Hard | Tree | |
1028 | Recover a Tree From Preorder Traversal | C++ | O(n) | O(n) | Hard | Tree |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
094 | Binary Tree Inorder Traversal | Java | O(n) | O(logn) | Medium | Binary Tree, Stack, HashTable | |
101 | Symmetric Tree | Java | O(n) | O(n) | Easy | Tree, Breadth-first Search, Depth-first Search | |
144 | Binary Tree Preorder Traversal | Java | O(n) | O(logn) | Medium | Binary Tree, Stack | |
145 | Binary Tree Postorder Traversal | Java | O(n) | O(logn) | Hard | Binary Tree, Stack | |
103 | ZigZag Level Order | JavaScript | O(n) | O(n) | Medium | Binary Tree | |
129 | Sum Root to Leaf Numbers | Java | O(n) | O(logn) | Medium | Binary Tree, Depth First Search | |
307 | Range Sum Query - Mutable | Java | O(logn) | O(n) | Medium | Segment Tree | |
919 | Complete Binary Tree Inserter | Java | O(n) | O(n) | Medium | Tree |
# | Title | Solution | Time | Space | Difficulty | Tag | Video Explanation |
---|---|---|---|---|---|---|---|
001 | Two Sum | Java Python |
O(N) | O(N) | Easy | Tutorial | |
242 | Valid Anagram | Java | O(n) | O(1) | Easy | Tutorial | |
146 | LRU Cache | Java | Medium |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
005 | Longest Palindromic Substring | Python | O(N^2) | O(N) | Medium | Expand the Wings |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
050 | Pow(x, n) | Python | O(n) | O(1) | Medium | Math | |
204 | Count Primes | C++ | O(n(log(logn))) | O(n) | Easy | Math | |
168 | Excel Sheet Column Title | C++ | O(n) | O(n) | Easy | String | |
007 | Reverse Integer | Java C++ |
O(n) | O(n) | Easy | Math |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1284 | Minimum Number of Flips to Convert Binary Matrix to Zero Matrix | C++ | O(m * n * 2 ^ (m * n)) | O(2 ^ (m * n)) | Hard | BFS | |
200 | Number of Islands | Java | O(R * C) | O(R * C) | Medium | BFS |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1463 | Cherry Pickup II | C++ | O(n * m) | O(n * m) | Hard | DFS |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
037 | Sudoku Solver | C++ | O(n^2) | O(1) | Hard | Hash Table | |
980 | Unique Paths III | C++ | O(R * C * 2 ^ (R * C)) | O(R * C) | Hard | DFS, Memoization |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
416 | Partition Equal Subset Sum | C++ | O(n^2) | O(n^2) | Medium | DP | |
056 | Wildcard Matching | Python | O(n^2) | O(n^2) | Hard | ||
343 | Integer Break | C++ | O(n^2) | O(n) | Medium | ||
139 | Word Break | Python | O(n^3) | O(n) | Medium | DP | |
1092 | Shortest Common Supersequence | C++ | O(n^2) | O(n^2) | Hard | DP | |
72 | Edit Distance | Python | O(N*M) | O(n^2) | Medium | Levenshtein Distance | |
91 | Decode ways | Python | O(N) | O(N) | Easy | DP | |
1025 | Divisor Game | Python | O(N^2) | O(N) | Easy | DP |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
035 | Search Insert Position | Python | O(logn) | O(1) | Easy | Binary Search | |
278 | First Bad Version | Java JavaScript |
O(logn) | O(1) | Easy | Binary Search | |
033 | Search in Rotated Sorted Array | Python | O(logn) | O(1) | Medium | Binary Search | |
153 | Find Minimum in Rotated Sorted Array | Python | O(logn) | O(1) | Medium | Binary Search |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1042 | Flower Planting with No Adjacent | Python | O(V+E) | O(2V+E) | Medium | Graph | Graph Coloring |
1.) Cracking the Coding Interview (Indian Edition)
2.) Data Structures and Algorithms Made Easy in Java
3.) Data Structure and Algorithmic Thinking with Python
4.) Head First Design Patterns
5.) Dynamic Programming for Coding Interviews
DISCLAIMER: This above mentioned resources have affiliate links, which means if you buy one of the product from my links, I’ll receive a small commission. This helps support the channel and allows us to continue to add more tutorial. Thank you for the support!
Name | Country | Programming Language | Where to find you (add all links to your profiles eg on Hackerrank, Codechef, LeetCode...) |
---|---|---|---|
Gourav R |
India | Java | codedecks Hackerrank |
Lokendra Bohra |
India | Python | Leetcode Hackerrank |
Yuri Spiridonov |
Russia | Python | Twitter Leetcode Hackerrank |
Naveen Kashyap |
India | Javascript | Twitter Leetcode |
Rudra Mishra |
India | C++ | Twitter Leetcode |
Sachin Singh Negi |
India | Python | Twitter Leetcode Hackerrrak |
Girish Thatte |
India | Java | Leetcode Hackerrank Codechef |
Kevin Chittilapilly |
India | Java | Leetcode Hackerrank Kaggle |
Nour Grati |
Tunisia | Python | Leetcode Hackerrank |