Including problem statement, solution, runtime and complexity analysis.
HassanElDesouky/AwesomeLeetCodeDiscussions
Important and Useful links from all over the Leetcode
Interview Preparation for Beginners - [ DS | Algorithms | OS | System Design ]
A few helpful links to posts which tell you HOW to grind leetcode
Comprehensive Data Structure and Algorithm Study Guide
Preorder, Inorder, and Postorder Iteratively Summarization
94. Binary Tree Inorder Traversal.cpp
173. Binary Search Tree Iterator.cpp
144. Binary Tree Preorder Traversal.cpp
145. Binary Tree Postorder Traversal.cpp
Morris Traversal方法遍历二叉树(非递归,不用栈,O(1)空间)
94. Binary Tree Inorder Traversal.cpp
99. Recover Binary Search Tree.cpp
538. Convert BST to Greater Tree.cpp
1617. Count Subtrees With Max Distance Between Cities.cpp
Graph Problems For Beginners Practice [Problems and Sample Solutions]
relax for V-1 times, works for negative weighted edges, time complexity: O(VE)
SPFA(Shortest Path Faster Algorithm)
greedy, not work for negative weighted edges
DS | time complexity |
---|---|
adjacency matrix | O(V^2) |
adjacency list + binary heap | O(ElogV) |
adjacency list + Fabonacci heap | O(VlogV + E) |
Dijkstra’s algorithm - theorem
Dijkstra's algorithm - C++ implementation
Articulation Points (or Cut Vertices) in a Graph
1568. Minimum Number of Days to Disconnect Island.cpp
1192. Critical Connections in a Network.cpp
Detect Cycle in a Directed Graph
Detect cycle in an undirected graph: the text description is wrong, watch the video
1559. Detect Cycles in 2D Grid.cpp
Prim’s Minimum Spanning Tree (MST) | Greedy Algo-5
Minimum cost to connect all cities
1584. Min Cost to Connect All Points.cpp
11. Container With Most Water.cpp
26. Remove Duplicates from Sorted Array.cpp
80. Remove Duplicates from Sorted Array II.cpp
76. Minimum Window Substring.cpp
167. Two Sum II - Input array is sorted.cpp
234. Palindrome Linked List.cpp
287. Find the Duplicate Number.cpp
345. Reverse Vowels of a String.cpp
349. Intersection of Two Arrays.cpp
350. Intersection of Two Arrays II.cpp
424. Longest Repeating Character Replacement.cpp
524. Longest Word in Dictionary through Deleting.cpp
844. Backspace String Compare.cpp
977. Squares of a Sorted Array.cpp
986. Interval List Intersections.cpp
1004. Max Consecutive Ones III.cpp
1248. Count Number of Nice Subarrays.cpp
1574. Shortest Subarray to be Removed to Make Array Sorted.cpp
Sliding Window for Beginners [Problems | Template | Sample Solutions]
713. Subarray Product Less Than K.cpp
Python solution using monotonic stack, similar pattern questions listed
84. Largest Rectangle in Histogram.cpp
503. Next Greater Element II.cpp
1475. Final Prices With a Special Discount in a Shop.cpp
1504. Count Submatrices With All Ones.cpp
Monotonic Queue Explained with LeetCode Problems
122. Best Time to Buy and Sell Stock II.cpp
239. Sliding Window Maximum.cpp
918. Maximum Sum Circular Subarray.cpp
1425. Constrained Subsequence Sum.cpp
1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit.cpp
1499. Max Value of Equation.cpp
It serves as Self-balancing Binary Search Trees (like an AVL Tree).
295. Find Median from Data Stream.cpp
332. Reconstruct Itinerary.cpp
480. Sliding Window Median.cpp
Detailed explanation and generalization of the bitwise operation method for single numbers
187. Repeated DNA Sequences.cpp
239. Sliding Window Maximum.cpp
477. Total Hamming Distance.cpp
Binary Search for Beginners [Problems | Patterns | Sample solutions]
Summary of solutions for problems "reducible" to LeetCode 378
378. Kth Smallest Element in a Sorted Matrix.cpp
373. Find K Pairs with Smallest Sums.cpp
668. Kth Smallest Number in Multiplication Table.cpp
719. Find K-th Smallest Pair Distance.cpp
786. K-th Smallest Prime Fraction.cpp
35. Search Insert Position.cpp
167. Two Sum II - Input array is sorted.cpp
230. Kth Smallest Element in a BST.cpp
240. Search a 2D Matrix II.cpp
287. Find the Duplicate Number.cpp
349. Intersection of Two Arrays.cpp
350. Intersection of Two Arrays II.cpp
374. Guess Number Higher or Lower.cpp
744. Find Smallest Letter Greater Than Target.cpp
852. Peak Index in a Mountain Array.cpp
981. Time Based Key-Value Store.cpp
1011. Capacity To Ship Packages Within D Days.cpp
1111. Maximum Nesting Depth of Two Valid Parentheses Strings.cpp
1235. Maximum Profit in Job Scheduling.cpp
1237. Find Positive Integer Solution for a Given Equation.cpp
131. Palindrome Partitioning.cpp
211. Add and Search Word - Data structure design.cpp
784. Letter Case Permutation.cpp
1079. Letter Tile Possibilities.cpp
1219. Path with Maximum Gold.cpp
1286. Iterator for Combination.cpp
DP for Beginners [Problems | Patterns | Sample Solutions]
Checking for "Overlapping subproblem" property
How to solve DP - String? Template and 4 Steps to be followed.
My experience and notes for learning DP
303. Range Sum Query - Immutable.cpp
647. Palindromic Substrings.cpp
746. Min Cost Climbing Stairs.cpp
931. Minimum Falling Path Sum.cpp
983. Minimum Cost For Tickets.cpp
1027. Longest Arithmetic Sequence.cpp
1048. Longest String Chain.cpp
1074. Number of Submatrices That Sum to Target.cpp
1130. Minimum Cost Tree From Leaf Values.cpp
1143. Longest Common Subsequence.cpp
1147. Longest Chunked Palindrome Decomposition.cpp
1235. Maximum Profit in Job Scheduling.cpp
1277. Count Square Submatrices with All Ones.cpp
1289. Minimum Falling Path Sum II.cpp
1359. Count All Valid Pickup and Delivery Options.cpp
1397. Find All Good Strings.cpp
1405. Longest Happy String.cpp
Leetcode discussion - Most consistent ways of dealing with the series of stock problems
121. Best Time to Buy and Sell Stock.cpp
122. Best Time to Buy and Sell Stock II
123. Best Time to Buy and Sell Stock III.cpp
188. Best Time to Buy and Sell Stock IV.cpp
309. Best Time to Buy and Sell Stock with Cooldown.cpp
714. Best Time to Buy and Sell Stock with Transaction Fee.cpp
416. Partition Equal Subset Sum.cpp
300. Longest Increasing Subsequence.cpp
354. Russian Doll Envelopes.cpp
368. Largest Divisible Subset.cpp
124. Binary Tree Maximum Path Sum.cpp
543. Diameter of Binary Tree.cpp
902. Numbers At Most N Given Digit Set.cpp
1015. Smallest Integer Divisible by K.cpp
96. Unique Binary Search Trees.cpp
957. Prison Cells After N Days.cpp
1137. N-th Tribonacci Number.cpp
794. Valid Tic-Tac-Toe State.cpp
1275. Find Winner on a Tic Tac Toe Game.cpp
329. Longest Increasing Path in a Matrix.cpp
576. Out of Boundary Paths.cpp
A simple tutorial on this bitmasking problem
526. Beautiful Arrangement.cpp
698. Partition to K Equal Sum Subsets
1349. Maximum Students Taking Exam.cpp
1434. Number of Ways to Wear Different Hats to Each Other.cpp
1595. Minimum Cost to Connect Two Groups of Points.cpp
KMP Algorithm for Pattern Searching
187. Repeated DNA Sequences.cpp
1392. Longest Happy Prefix.cpp
1397. Find All Good Strings.cpp
1408. String Matching in an Array.cpp
Longest Palindromic Substring O(N) Manacher's Algorithm
Manacher’s Algorithm – Linear Time Longest Palindromic Substring – Part 4
[译]最长回文子串(Longest Palindromic Substring) Part I
[译+改]最长回文子串(Longest Palindromic Substring) Part II
5. Longest Palindromic Substring.cpp
647. Palindromic Substrings.cpp
Greedy for Beginners [Problems | Sample solutions]
435. Non-overlapping Intervals.cpp
452. Minimum Number of Arrows to Burst Balloons.cpp
1589. Maximum Sum Obtained of Any Permutation.cpp
1109. Corporate Flight Bookings.cpp
Why is the base used to compute hashes in Rabin–Karp always primes?
686. Repeated String Match.cpp
1044. Longest Duplicate Substring.cpp
1147. Longest Chunked Palindrome Decomposition.cpp
1071. Greatest Common Divisor of Strings.cpp
Article on Trie. General Template and List of problems.
208. Implement Trie (Prefix Tree).cpp
211. Add and Search Word - Data structure design.cpp
1268. Search Suggestions System.cpp
676. Implement Magic Dictionary.cpp
720. Longest Word in Dictionary.cpp
Trie, Suffix Tree, Suffix Array
Ukkonen's suffix tree algorithm in plain English
1408. String Matching in an Array.cpp
Union find problems look alike graph problems, if we only care whether two nodes are connected, not their distance, we should use union find.(?, inspired by 1627)
959. Regions Cut By Slashes.cpp
1391. Check if There is a Valid Path in a Grid.cpp
128. Longest Consecutive Sequence.cpp
1559. Detect Cycles in 2D Grid.cpp
1562. Find Latest Group of Size M.cpp
1627. Graph Connectivity With Threshold
307. Range Sum Query - Mutable(solution)
A Recursive approach to Segment Trees, Range Sum Queries & Lazy Propagation
307. Range Sum Query - Mutable Medium.cpp
315. Count of Smaller Numbers After Self.cpp
673. Number of Longest Increasing Subsequence.cpp
1505. Minimum Possible Integer After at Most K Adjacent Swaps On Digits.cpp
Java using Binary Indexed Tree with clear explanation
Topcode binary indexed trees tutorial
307. Range Sum Query - Mutable Medium.cpp
315. Count of Smaller Numbers After Self.cpp
1395. Count Number of Teams.cpp
1505. Minimum Possible Integer After at Most K Adjacent Swaps On Digits.cpp
Binary Indexed Tree : Range Updates and Point Queries
1589. Maximum Sum Obtained of Any Permutation.cpp
1109. Corporate Flight Bookings.cpp
1589. Maximum Sum Obtained of Any Permutation.cpp
1453. Maximum Number of Darts Inside of a Circular Dartboard.cpp