codedecks-in / Leetcode Solutions
Licence: mit
This repository consists of solutions to the problem from LeetCode platform. Subscribe to our Channel for more updates
Stars: ✭ 128
Programming Languages
java
68154 projects - #9 most used programming language
Projects that are alternatives of or similar to Leetcode Solutions
Competitive Programming
Hello Programmers 💻 , A one-stop Destination✏️✏️ for all your Competitive Programming Resources.📗📕 Refer CONTRIBUTING.md for contributions
Stars: ✭ 113 (-11.72%)
Mutual labels: hacktoberfest, beginner-friendly, first-timers, leetcode
Plots2
a collaborative knowledge-exchange platform in Rails; we welcome first-time contributors! 🎈
Stars: ✭ 666 (+420.31%)
Mutual labels: hacktoberfest, beginner-friendly, help-wanted, first-timers
Hello World
Hello World in all possible programmnig languages
Stars: ✭ 558 (+335.94%)
Mutual labels: hacktoberfest, beginner-friendly, help-wanted, first-timers
Awesome Hacktoberfest 2020
A curated list of awesome Hacktoberfest 2020 repositories, guides and resources
Stars: ✭ 349 (+172.66%)
Mutual labels: hacktoberfest, beginner-friendly, first-timers
leetcode-java
🎓🎓🎓 Leetcode solution in Java - 536/921 Solved. https://leetcode.com/problemset/all/
Stars: ✭ 56 (-56.25%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
Leetcode
Leetcode solutions
Stars: ✭ 2,894 (+2160.94%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
CodingInterview
Leetcode解题、剑指offer第二版💪💪💪⛷😀
Stars: ✭ 28 (-78.12%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
Gitstart
Make a Pull Request
Stars: ✭ 415 (+224.22%)
Mutual labels: hacktoberfest, beginner-friendly, help-wanted
Hacktoberfest
Hacktoberfest 2018. Check out the end video for this project ->
Stars: ✭ 406 (+217.19%)
Mutual labels: hacktoberfest, beginner-friendly, help-wanted
Awesome Java Leetcode
👑 LeetCode of algorithms with java solution(updating).
Stars: ✭ 8,297 (+6382.03%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
Leetcode
LeetCode刷题记录与面试整理
Stars: ✭ 6,469 (+4953.91%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
Hacktoberfest2k19
Hacktoberfest is here! Raise the PR and earn goodies.
Stars: ✭ 34 (-73.44%)
Mutual labels: hacktoberfest, beginner-friendly, help-wanted
leetcode-solution-curation
A one-stop repository for LeetCode solutions.
Stars: ✭ 31 (-75.78%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
CodingInterview
Solutions to Leetcode, CareerCup Coding problems
Stars: ✭ 64 (-50%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
Leetcode
LeetCode Top 100 Liked Questions | Top Interview Questions | LeetCode 用户最喜欢的100题 | 面试最容易被问到的题
Stars: ✭ 312 (+143.75%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
data-structures-and-algorithms
Important data structures and algorithms implemented in Java along with solutions to AlgoExpert problems and some Leetcode problems.
Stars: ✭ 222 (+73.44%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
Leetcode-solutions
Leetcode Grinder.
Stars: ✭ 14 (-89.06%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
LeetCode-Solution-Well-Explained
My LeetCode solutions using Java. Sorted in different topics and add detailed comments for easy understanding.
Stars: ✭ 23 (-82.03%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
Hacktoberfest 2020
Welcome to Open-source! Simply add your details to contributors | Repo for Hacktoberfest 2020 ✅
Stars: ✭ 621 (+385.16%)
Mutual labels: hacktoberfest, beginner-friendly, first-timers
Onlinejudge Solutions
Collection of solutions to online judge problems
Stars: ✭ 45 (-64.84%)
Mutual labels: leetcode, leetcode-solutions, leetcode-java
LeetCode-Solutions
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.
PR process
If you want to contribute, please create a Pull Request. If you are new to Github please check pull request procedure --->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.
Don't forget to give us a 🌟 to support us.
Learning Resources
Check out ->Algorithms
- 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
Bit Manipulation
# | Title | Solution | Time | Space | Difficulty | Tag | Tutorial |
---|---|---|---|---|---|---|---|
136 | Single Number |
Java Python C++ |
O(n) | O(1) | Easy | Using XOR | |
137 | Single Number II | Python | O(n) | O(1) | Medium | ||
260 | Single Number III | Python | O(n) | O(1) | Medium | ||
476 | Number Complement | Java | O(1) | O(1) | Easy | Tutorial | |
520 | Detect Capital Use | Python | O(n) | O(1) | Easy | ||
1486 | XOR Operation in an Array | Java | O(n) | O(1) | Easy | Using XOR |
Sort
# | Title | Solution | Time | Space | Difficulty | Tag | Tutorial |
---|---|---|---|---|---|---|---|
973 | K Closest Points to Origin | C++ | O(n) | O(1) | Medium |
Array
# | 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 C++ |
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 | |
1134 🔒 | Armstrong Number | Java | O(N) | O(1) | Easy | ||
1534 | Count Good Triplets | Python | O(N^3) | O(1) | Easy | ||
1572 | Matrix Diagonal Sum | Java | O(N) | O(1) | Easy | ||
811 | Subdomain Visit Count | Javascript | O(N*M) | O(N*M + N) | Easy | ||
53 | Maximum Subarray | C++ | O(N) | O(1) | Easy | Array | |
495 | Teemo Attacking | C++ | O(n) | O(1) | Medium | Array | |
15 | 3 Sum | Python | O( nLog(n) ) | O(1) | Medium | Array | |
1200 | Minimum Absolute Difference | Python | O(n) | O(1) | Easy | Array | |
532 | K-diff Pairs in an Array | C++ | O(n) | O(n) | Medium | Array | |
152 | Maximum Product Subarray | Javascript | O(n) | O(n) | Medium | Array | |
073 | Set-Matrix-Zeroes | Java | O(MN) | O(1) | Medium | Array | |
1288 | Remove-Covered-Intervals | C++ | O(N*N) | O(1) | Medium | Array | |
189 | Rotate-Array | Python | O(N) | O(1) | Medium | Array | |
496 | next-greater-element-i | Python | O(N) | O(1) | Medium | Array | |
1470 | Shuffle the Array | Java | O(N) | O(1) | Easy | Array | |
124 | Permutation by Recussion | Java | O(N) | O(N) | Easy | Array | |
283 | Move-Zeroes | C++ | O(N) | O(1) | Easy | Array | |
27 | Remove-Element | C++ | O(N) | O(1) | Easy | Array | |
36 | Valid Sudoku | Java | O(N^2) | O(N) | Medium | Array, 2D Matrix | |
1512 | Number of Good Pairs | Java | O(N^2) | O(1) | Easy | Array |
String
# | 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 | ||
1614 | Maximum Nesting Depth of the Parentheses | Java | O(n) | O(1) | Easy | ||
1374 | Generate a String With Characters That Have Odd Counts | Java | O(n) | O(1) | Easy | ||
859 | Buddy Strings | Java | O(n) | O(1) | Easy | ||
9 | Palindrome Number | Java | O(n) | O(1) | Easy | ||
767 | Reorganize String | Python | O(n) | O(n) | Medium |
Linked List
# | Title | Solution | Time | Space | Difficulty | Tag | Tutorial |
---|---|---|---|---|---|---|---|
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 | |
23 | Merge K sorted lists | C++ | O(nlogn) | O(n) | Hard | sorting and append | |
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 | |
142 | Linked List Cycle II |
Java C++ |
O(n) | O(1) | Medium | Slow-Fast Pointers | |
146 | LRU Cache |
C++ Python |
O(1) | O(k) | Medium | Hash Map | |
160 | Intersection of Two Linked Lists | Java | O(n) | O(1) | Easy | Two Pointers | Tutorial |
186 | Middle of the Linked List | Java | O(n) | O(1) | Easy | Two pointers |
Stack
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
020 | Valid Parentheses | Python | O(n) | O(n) | Easy | Stack | |
084 | Largest Rectangle in Histogram | C++ | O(n) | O(n) | Hard | Stack | |
150 | Evaluate Reverse Polish Notation | Python | O(n) | O(1) | Medium | Stack | |
1047 | Remove All Adjacent Duplicates In String | C++ | O(n) | O(n) | Easy | Stack | |
682 | Baseball Game | C++ | O(n) | O(n) | Easy | Stack | |
1381 | Design a Stack With Increment Operation | Java | O(n) | O(n) | Medium | Stack | |
1598 | Crawler Log Folder | C++ | O(n) | O(n) | Easy | Stack | |
94 | Binary Tree Inorder Traversal | Python | O(n) | O(n) | Medium | Recursion, Binary Tree | |
735 | Asteroid Collision | C++ | O(n) | O(1) | Medium | Stack | |
394 | Decode String | C++ | O(n) | O(1) | Medium | Stack | |
921 | Minimum Add to Make Parentheses Valid | C++ | O(n) | O(1) | Medium | Stack | |
32 | Longest Valid Parentheses | Python | O(n) | O(n) | Hard | Stack | |
1249 | Minimum Remove to Make Valid Parentheses | C++ | O(n) | O(n) | Medium | Stack |
Queue
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
933 | Number of Recent Calls | C++ | O(1) | O(1) | Easy | Queue, Sliding Window | |
641 | Design Circular Deque | Java | O(n) | O(n) | Medium | Queue, Design | |
621 | Task Scheduler | Python | O(n) | O(n) | Medium | Queue | |
622 | Design Circular Queue | Python | O(n) | O(n) | Medium | Queue |
Tree
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
094 | Binary Tree Inorder Traversal |
Java Python |
O(n) | O(logn) | Medium | Binary Tree, Stack, HashTable | |
100 | Same Tree |
Python Java |
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 C++ |
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 | |
968 | Binary Tree Cameras | C++ | O(n) | O(logn) | Hard | Binary Tree, Dynamic Programming | |
98 | Validate Binary Search Tree | Javascript | O(log(n)) | O(log(n)) | Medium | Binary Tree | |
684 | Redundant Connection | Java | O(N) | O(N) | Medium | Tree, Union Find |
Hash Table
# | Title | Solution | Time | Space | Difficulty | Tag | Video Explanation |
---|---|---|---|---|---|---|---|
001 | Two Sum |
Java Python C++ |
O(N) | O(N) | Easy | Tutorial | |
242 | Valid Anagram | Java | O(n) | O(1) | Easy | Tutorial | |
146 | LRU Cache | Java | Medium | ||||
217 | Contains Duplicate | Python | O(n) | O(n) | |||
554 | Brick Wall | C++ | O(n) | O(n) | Medium | ||
049 | Group Anagrams | Python | O(nlogn) | O(1) | Easy | ||
554 | Brick Wall | C++ | O(n) | O(n) | Medium | ||
146 | LRU Cache | Javascript | O(log(n)) | O(n) | Medium | ||
389 | Find The Difference | C++ | O(n) | O(1) | Easy |
Two Pointers
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
005 | Longest Palindromic Substring |
Python JavaScript |
O(N^2) O(N^2) |
O(N) O(1) |
Medium | Expand the Wings | |
4 | Median of Two Sorted Arrays | Java | O(log(min(m,n))) | O(1) | Hard | ||
845 | Longest Mountain in Array | C++ | O(N) | O(1) | Medium | Two Pointer | |
015 | 3 Sum | C++ | O(N) | O(1) | Medium | Two Pointer |
Math
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
050 | Pow(x, n) |
Python JavaScript |
O(n) | O(1) | Medium | Math | |
204 | Count Primes | C++ | O(n(log(logn))) | O(n) | Easy | Math | |
171 | Excel Sheet Column Number | C++ | O(n) | O(1) | Easy | String | |
168 | Excel Sheet Column Title | C++ | O(n) | O(n) | Easy | String | |
007 | Reverse Integer |
Java C++ |
O(n) | O(n) | Easy | Math | |
202 | Happy Number | Java | O(n^2) | O(n) | Easy | Math | |
326 | Power of Three | Java | O(logn) | O(n) | Easy | Math | |
12 | Integer to Roman | Java | O(n) | O(1) | Medium | Math | |
13 | Roman to Integer | Java | O(n) | O(1) | Easy | Math | |
14 | Arithmetic Subarrays | Java | O(m*n) | O(n) | Medium | Math | Pattern Count |
263 | Ugly Number | Java | O(n) | O(n) | Easy | Math |
Breadth-First Search
# | 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 | |
127 | Word Ladder | Java | O(N^2 * M) | O(N * M) | Medium | BFS | |
994 | Rotten Oranges | Python | O(N * M) | O(N * M) | Medium | BFS | |
743 | Network Delay Time | C++ | O(V+E)) | O(V) | Medium | BFS | |
111 | Min Depth of Binary Tree | JavaScript | O(nlogn) | O(nlogn) | Easy | BFS |
Depth-First Search
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1463 | Cherry Pickup II | C++ | O(n * m) | O(n * m) | Hard | DFS | |
104 | Maximum Depth of Binary Tree | python | O(n) | O(n) | Easy | DFS | |
112 | Path Sum | Java | O(n) | O(n) | Easy | DFS | |
110 | Balanced Binary Tree | Java | O(n) | O(n) | Easy | DFS |
BackTracking
# | 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 | |
39 | Combination Sum | C++ | O(2^n) | O(n) | Medium | Array, Backtracking |
Dynamic Programming
# | 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 | |
174 | Dungeon Game | C++ | O(M*N) | O(M*N) | Hard | Dynamic Programming | |
070 | Climbing Stairs | Java | O(N) | O(1) | Easy | DP | |
730 | Count Different Palindromic Subsequences | C++ | O(N*N) | O(N*N) | Hard | DP |
Binary Search
# | 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 | |
704 | Binary Search | C++ | O(logn) | O(1) | Easy | Binary Search |
Graph
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
207 | Course Schedule | C++ | O(V+E) | O(V+E) | Medium | Graph | Cycle Detection in Directed Graph |
1042 | Flower Planting with No Adjacent | Python | O(V+E) | O(2V+E) | Medium | Graph | Graph Coloring |
797 | All Paths From Source to Target | Java | O(N^2) | O(N) | Medium | Graph | DFS |
934 | Shortest Bridge | C++ | O(V) | O(V) | Medium | Graph | DFS + BFS |
1192 | Critical Connections in a Network | C++ | O(V+E) | O(4V+E) | Hard | Graph | Tarjan's Algorithm |
113 | Path Sum II | C++ | O(V+E) | O(V) | Medium | Graph | DFS |
785 | Is Graph Bipartite? | C++ | O(V+E) | O(V) | Medium | Graph | BFS |
947 | Most Stones Removed with Same Row or Column | C++ | O(V) | O(2V) | Medium | Graph | Union Find |
210 | Course Schedule II | C++ | O(V+E) | O(V) | Medium | Graph | BFS |
1627 | Graph Connectivity with Threshold | Java | O(V.logV + Q) | O(V) | Hard | Graph | Union Find + Sieve |
1631 | Path with Minimum Effort | Java | O(V^2) | O(V) | Medium | Graph | Dijkstra's Shortest Path |
Learning Resources
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!
Authors
Contributors
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].