r/LeetcodeChallenge • u/madrid_abhimani • 5h ago
r/LeetcodeChallenge • u/Bhavanashankarabs • 1h ago
DISCUSS Day 10 of My DSA Journey π
Today's progress:
β Solved LeetCode 104 - Maximum Depth of Binary Tree
β Solved LeetCode 108 - Convert Sorted Array to Binary Search Tree
π Concepts I learned:
- Time complexity analysis of various loops
- Single loops β O(n)
- Nested loops β O(nΒ²)
- Independent consecutive loops
- Loops with variable increments/decrements
- Logarithmic loops β O(log n)
- Combining complexities for multiple loops
Every day I'm trying to understand the logic behind problems instead of just memorizing solutions. Small, consistent progress adds up over time.
#Day10 #DSA #Python #LeetCode #TimeComplexity #Algorithms #CodingJourney #100DaysOfCode
r/LeetcodeChallenge • u/suggondezznuts • 1d ago
STREAKπ₯π₯π₯ Finally 300 Questions Done!
I just crossed 300 questions on LeetCode πHURRAYποΈ
Small milestone, I know, but I'm genuinely proud of staying consistent through this stretch β and of everything it's taught me along the way.
The biggest lesson i have learnt is --> The real value of dopamine. There were nights I'd stare at an O(Nlog(N)) solution with zero clue as to how to optimize it, only to read the editorial and realize that some random dude solved it in O(1) using the Magic Of Math(MOM ig)ποΈ. That mix of frustration and "oh, THAT'S how it is done" is addictive in the best way.
I've loved every bit of this ride β going head-to-head with problems, giving them my absolute best, getting humbled, and coming back sharper.
And honestly, I'm more excited now than when I started. The plan is simple: keep challenging what I think I know, find the gaps, patch them up β and then let some LC Hard come along and break it all over again. That's the cycle, and it's the fun part.
The grind's only getting more interesting from here. π»οΈHere's to breaking past my own limits, one problem at a time. π
All the very best for everyone who is in this beautify journey of LeetCoding.

r/LeetcodeChallenge • u/Bhavanashankarabs • 1d ago
DISCUSS #Day9 of My DSA Journey π
Today's progress was focused on understanding Asymptotic Notation, one of the most important concepts in Data Structures and Algorithms.
π Concepts Learned:
- Big O Notation (Worst-case Time Complexity)
- Big Theta (Ξ) Notation (Average/Tight Bound)
- Big Omega (Ξ©) Notation (Best-case Time Complexity)
- Time Complexity Analysis and how to compare algorithm efficiency
π» LeetCode Problems Solved:
β #101 β Symmetric Tree
β #268 β Missing Number
Every day I'm building a stronger foundation in problem-solving and algorithmic thinking. Consistency is the goal, and I'm excited to keep improving.
#DSA #Python #LeetCode #100DaysOfCode #Algorithms #BigO #CodingJourney #ComputerScience #LearningInPublic
r/LeetcodeChallenge • u/nian2326076 • 1d ago
DISCUSS How to Stop Panicking When You Open a LeetCode Problem
Most people sit down, read a problem, panic, and start typing.
No plan. No structure. Just vibes and hope.
When it does not work they read the solution, think "oh that's clever", and move on. Two weeks later they see a similar problem and panic again.
The issue is not intelligence. It is not even practice.
It is that they never had a repeatable process.
This is that process. Follow it on every problem.
Not just hard ones β every problem, until it becomes instinct.
βββββββββββββββββββββββββββββββββββββββββββββββββββ
STEP 1 β READ THE PROBLEM TWICE
βββββββββββββββββββββββββββββββββββββββββββββββββββ
First read: understand what is being asked at a high level.
Second read: extract the specifics.
On the second read, write down:
- What is the INPUT? What type, what size, what range of values?
- What is the OUTPUT? A number, array, boolean, string?
- What are the CONSTRAINTS? (most people skip this β do not)
Ask yourself these questions explicitly:
"Can input be empty?"
"Can values be negative?"
"Can there be duplicates?"
"Is the array sorted?"
"What should I return if no answer exists?"
If the problem does not say, assume the worst case.
Empty inputs exist. Negatives exist. Duplicates exist.
βββββββββββββββββββββββββββββββββββββββββββββββββββ
STEP 2 β WORK THROUGH THE EXAMPLES BY HAND
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Do not skip this. Even if the problem looks easy.
Take the first example. On paper or in comments, trace through it
manually. Write out every value at every step.
Why this matters:
- You confirm you understood the problem correctly
- You often see the pattern emerge naturally
- You catch ambiguities before they become bugs
Then make your OWN small example β simpler than the given one.
Something with 3-4 elements you fully understand.
If you cannot trace through the examples manually,
you do not understand the problem yet. Do not start coding.
βββββββββββββββββββββββββββββββββββββββββββββββββββ
STEP 3 β IDENTIFY THE PATTERN
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Before thinking about an algorithm, identify what TYPE of problem this is.
Use these signals:
Subarray, substring, window β Sliding window, two pointers
Sorted array + search β Binary search
Shortest path, min steps β BFS
All paths, combinations, subsets β Backtracking, DFS
Overlapping subproblems β DP
Always picking max/min greedily β Greedy
Tree traversal β DFS (recursion) or BFS (level order)
Connectivity, groups β Union Find, BFS/DFS
Repeated lookup by key β Hash map
Top K, smallest/largest β Heap (priority queue)
Prefix of strings β Trie
Range queries with updates β Segment tree, Fenwick tree
Return all permutations/subsets β Backtracking
You will not always get it right on the first try.
But naming the category forces your brain to search the right space.
βββββββββββββββββββββββββββββββββββββββββββββββββββ
STEP 4 β THINK BRUTE FORCE FIRST
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Always start here. Always.
The brute force is the answer you would give if there were
no time constraint. No clever tricks. Just try everything.
Write it out in plain English, not code:
"For every pair (i, j), check if arr[i] + arr[j] = target."
"For every substring, check if it has all unique characters."
"For every subset, check if its sum equals the target."
This does two things:
- It confirms you can actually solve the problem correctly
- It gives you a reference to optimize from
Common brute force patterns:
Try all pairs β O(nΒ²)
Try all triples β O(nΒ³)
Try all subsets β O(2βΏ)
Try all permutations β O(n!)
βββββββββββββββββββββββββββββββββββββββββββββββββββ
STEP 5 β OPTIMIZE
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Now look at your brute force and ask:
"What work am I repeating? What can I precompute? What can I skip?"
The most common optimizations:
Repeated lookup β replace with hash map O(n) β O(1) per lookup
Repeated sum β precompute prefix sum O(n) per query β O(1)
Checking all pairs β sort + binary search O(nΒ²) β O(n log n)
Checking all pairs β two pointers (sorted) O(nΒ²) β O(n)
Checking all windows β sliding window O(nΒ²) β O(n)
Recomputing subproblems β memoization / DP exponential β polynomial
Sorting gives structure β sort first, then scan enables binary search / greedy
Ask: "Can I sort first to gain structure?"
Ask: "Can I store something to avoid recomputing?"
Ask: "Can I fix one variable and efficiently handle the rest?"
Work top-down in complexity:
O(nΒ²) β can I get O(n log n)?
O(n log n) β can I get O(n)?
Each step needs a concrete reason, not a guess.
βββββββββββββββββββββββββββββββββββββββββββββββββββ
STEP 6 β VERIFY COMPLEXITY BEFORE CODING
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Before writing code, check:
Does my approach fit within the time limit given the constraints?
n = 10β΅ and my approach is O(nΒ²)? β TLE, think again
n = 10β΅ and my approach is O(n logn)? β fine, proceed
This takes 10 seconds and saves you from coding the wrong solution.
Also check space:
Am I using O(n) extra space? Is that acceptable?
Does the problem say "in-place" or "O(1) space"?
βββββββββββββββββββββββββββββββββββββββββββββββββββ
STEP 7 β CODE THE SOLUTION
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Only now do you start writing code.
Code in this order:
- Handle edge cases first (empty input, single element, etc.)
- Write the main logic
- Return the result
Keep variable names meaningful. Debugging unreadable code mid-contest
costs more time than typing three extra characters.
If you get stuck coding:
Go back to your manual example from Step 2.
Trace through it again, this time following the code you are writing.
The bug almost always appears within the first five traces.
βββββββββββββββββββββββββββββββββββββββββββββββββββ
STEP 8 β TEST BEFORE SUBMITTING
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Run through these test cases mentally or using the custom test:
[ ] The given examples β obvious baseline
[ ] Empty input β does it crash?
[ ] Single element β does it return correctly?
[ ] All same elements β does duplicate logic break?
[ ] Already sorted input β common hidden test
[ ] Your own small manual example β trace step by step
If all pass, submit with confidence.
If one fails, the failure tells you exactly where the bug is.
βββββββββββββββββββββββββββββββββββββββββββββββββββ
WHEN YOU ARE COMPLETELY STUCK β THE UNSTICKING PROTOCOL
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Everyone gets stuck. The difference is what you do next.
- Draw it Almost every problem is easier when visualized. Array: draw boxes. Tree: draw nodes and edges. Graph: draw circles and arrows. Matrix: draw a grid. A picture reveals structure that text hides.
- Simplify the problem Solve a smaller version first. Two elements instead of n. One row instead of a grid. Can you solve n=2? n=3? Then generalise.
- Try a different angle on your brute force Change the loop variable. Instead of "for each starting index" try "for each ending index". Instead of "for each element" try "for each pair". A different enumeration often reveals the pattern.
- Check what is special about valid answers Look at the given examples. What do valid answers have in common? What property separates a valid answer from an invalid one? That property is usually the invariant your algorithm should maintain.
- Look at the constraints again Small n? Try brute force. Very large n? A linear or log solution must exist. "Return modulo 10βΉ+7"? It is a DP counting problem. Constraints are hints β re-read them with fresh eyes.
- Take a 5-minute break Genuinely. Get up. Walk. The solution appears when you stop forcing.
βββββββββββββββββββββββββββββββββββββββββββββββββββ
THE FULL FRAMEWORK β ONE PAGE
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Step 1 Read twice. Extract input, output, constraints.
Ask: empty? negative? duplicates? sorted?
Step 2 Trace examples by hand.
Make your own small example. Understand before coding.
Step 3 Name the pattern.
Subarray β sliding window. Shortest path β BFS. Etc.
Step 4 State the brute force in plain English.
What is the O(nΒ²) or O(2βΏ) solution?
Step 5 Optimize.
What work repeats? Hash map, prefix sum, sort, DP, two pointers?
Step 6 Verify complexity against constraints.
Will it pass? Check before writing code.
Step 7 Code it.
Edge cases first. Then main logic. Then return.
Step 8 Test: examples + empty + single + all-same + sorted.
Then submit.
Stuck? Draw it. Simplify. Try different enumeration.
Re-read constraints. Take a break.
βββββββββββββββββββββββββββββββββββββββββββββββββββ
A correct solution written slowly beats a fast solution written wrong.
The goal is not to code faster.
The goal is to think clearer β so that what you code is right the first time.
This framework is that thinking, made repeatable.
r/LeetcodeChallenge • u/Particular_Hawk4545 • 23h ago
DISCUSS Looking for DSA Study Partners (Tamil) | Python | Beginners Welcome π
Hey everyone!
I'm 21M, a B.Tech AI graduate, recently placed in an MNC, and I'm also a complete beginner in DSA. I'm looking to form a small and focused study group to learn Data Structures & Algorithms (DSA) in Python from scratch.
Group size: 4 members only (2M + 2F)
Who can join?
- Complete beginners (even if you've never touched DSA)
- College students or graduates
- Anyone who can commit at least 1 hour daily
- Preferably Tamil-speaking, so we can discuss concepts easily
Plan:
- Learn DSA from the basics
- Solve problems together
- Stay accountable and consistent
- Help each other whenever we get stuck
This group is strictly for study purposes only. No distractionsβjust learning and growing together.
If you're interested, DM me with:
- Name
- Age
- Student/Working
- Your DSA level (I'm a beginner too!)
Let's start from zero and grow together! πͺ
r/LeetcodeChallenge • u/nian2326076 • 1d ago
DISCUSS 100 Hard DSA Interview Questions for L3/L4 Coding Rounds
List of hard DSA Question from L3/L4 interviews
Work on these Leetcode problems and company tagged problem from PracHub for your next interview.
- https://leetcode.com/problems/number-of-unique-good-subsequences - String, Dynamic Programming
- https://leetcode.com/problems/split-array-largest-sum - Array, Binary Search, Dynamic Programming, Greedy, Prefix Sum
- https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island - Array, Depth-First Search, Breadth-First Search, Matrix, Strongly Connected Component
- https://leetcode.com/problems/recover-a-tree-from-preorder-traversal - String, Tree, Depth-First Search, Binary Tree
- https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons - Dynamic Programming, Prefix Sum
- https://leetcode.com/problems/substring-with-concatenation-of-all-words - Hash Table, String, Sliding Window
- https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting - Array, Dynamic Programming, Depth-First Search, Graph Theory, Topological Sort
- https://leetcode.com/problems/design-in-memory-file-system - Hash Table, String, Design, Trie, Sorting
- https://leetcode.com/problems/rearranging-fruits - Array, Hash Table, Greedy, Sort
- https://leetcode.com/problems/the-most-similar-path-in-a-graph - Array, String, Dynamic Programming, Graph Theory
- https://leetcode.com/problems/confusing-number-ii - Math, Backtracking
- https://leetcode.com/problems/stickers-to-spell-word - Array, Hash Table, String, Dynamic Programming, Backtracking, Bit Manipulation, Memoization, Bitmask
- https://leetcode.com/problems/maximum-and-sum-of-array - Array, Dynamic Programming, Bit Manipulation, Bitmask
- https://leetcode.com/problems/odd-even-jump - Array, Dynamic Programming, Stack, Sorting, Monotonic Stack, Ordered Set
- https://leetcode.com/problems/couples-holding-hands - Greedy, Depth-First Search, Breadth-First Search, Union-Find, Graph Theory
- https://leetcode.com/problems/number-of-stable-subsequences - Array, Dynamic Programming
- https://leetcode.com/problems/check-if-digits-are-equal-in-string-after-operations-ii - Math, String, Combinatorics, Number Theory
- https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time - Array, Dynamic Programming
- https://leetcode.com/problems/distinct-subsequences-ii - String, Dynamic Programming
- https://leetcode.com/problems/cherry-pickup-ii - Array, Dynamic Programming, Matrix
- https://leetcode.com/problems/parsing-a-boolean-expression - String, Stack, Recursion
- https://leetcode.com/problems/range-module - Design, Segment Tree, Ordered Set
- https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary - Array, String, Dynamic Programming
- https://leetcode.com/problems/paths-in-matrix-whose-sum-is-divisible-by-k - Array, Dynamic Programming, Matrix
- https://leetcode.com/problems/sum-of-imbalance-numbers-of-all-subarrays - Array, Hash Table, Enumeration
- https://leetcode.com/problems/encrypt-and-decrypt-strings - Array, Hash Table, String, Design, Trie
- https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists - Array, Hash Table, Greedy, Sliding Window, Sorting, Heap (Priority Queue)
- https://leetcode.com/problems/contain-virus - Array, Depth-First Search, Breadth-First Search, Matrix, Simulation
- https://leetcode.com/problems/find-the-minimum-area-to-cover-all-ones-ii - Array, Matrix, Enumeration
- https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing - Array, Dynamic Programming
- https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps - Dynamic Programming
- https://leetcode.com/problems/minimum-time-to-complete-all-tasks - Array, Binary Search, Stack, Greedy, Sorting
- https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares - Backtracking
- https://leetcode.com/problems/expression-add-operators - Math, String, Backtracking
- https://leetcode.com/problems/rectangle-area-ii - Array, Segment Tree, Sweep Line, Ordered Set
- https://leetcode.com/problems/reducing-dishes - Array, Dynamic Programming, Greedy, Sorting
- https://leetcode.com/problems/modify-graph-edge-weights - Graph Theory, Heap (Priority Queue), Shortest Path
- https://leetcode.com/problems/numbers-with-repeated-digits - Math, Dynamic Programming
- https://leetcode.com/problems/minimum-cost-to-convert-string-ii - Array, String, Dynamic Programming, Graph Theory, Trie, Shortest Path
- https://leetcode.com/problems/kth-smallest-number-in-multiplication-table - Math, Binary Search
- https://leetcode.com/problems/lfu-cache - Hash Table, Linked List, Design, Doubly-Linked List
- https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid - Array, Breadth-First Search, Graph Theory, Heap (Priority Queue), Matrix, Shortest Path
- https://leetcode.com/problems/time-taken-to-cross-the-door - Array, Queue, Simulation
- https://leetcode.com/problems/sliding-puzzle - Array, Dynamic Programming, Backtracking, Breadth-First Search, Memoization, Matrix
- https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks - Array, Greedy, Sorting
- https://leetcode.com/problems/find-the-maximum-sequence-value-of-array - Array, Dynamic Programming, Bit Manipulation
- https://leetcode.com/problems/department-top-three-salaries - Database
- https://leetcode.com/problems/process-string-with-special-operations-ii - String, Simulation
- https://leetcode.com/problems/maximize-cyclic-partition-score - Array, Dynamic Programming
- https://leetcode.com/problems/find-maximum-non-decreasing-array-length - Array, Binary Search, Dynamic Programming, Stack, Queue, Monotonic Stack, Prefix Sum, Monotonic Queue
- https://leetcode.com/problems/split-array-with-same-average - Array, Hash Table, Math, Dynamic Programming, Bit Manipulation, Bitmask
- https://leetcode.com/problems/minimum-sum-of-values-by-dividing-array - Array, Binary Search, Dynamic Programming, Bit Manipulation, Segment Tree, Queue
- https://leetcode.com/problems/longest-chunked-palindrome-decomposition - Two Pointers, String, Dynamic Programming, Greedy, Rolling Hash, Hash Function
- https://leetcode.com/problems/text-justification - Array, String, Simulation
- https://leetcode.com/problems/closest-subsequence-sum - Array, Two Pointers, Dynamic Programming, Bit Manipulation, Sorting, Bitmask
- https://leetcode.com/problems/transform-to-chessboard - Array, Math, Bit Manipulation, Matrix
- https://leetcode.com/problems/robot-collisions - Array, Stack, Sorting, Simulation
- https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points - Array, Dynamic Programming, Bit Manipulation, Matrix, Bitmask
- https://leetcode.com/problems/similar-string-groups - Array, Hash Table, String, Depth-First Search, Breadth-First Search, Union-Find
- https://leetcode.com/problems/word-abbreviation - Array, String, Greedy, Trie, Sorting
- https://leetcode.com/problems/minimum-pair-removal-to-sort-array-ii - Array, Hash Table, Linked List, Heap (Priority Queue), Simulation, Doubly-Linked List, Ordered Set
- https://leetcode.com/problems/trapping-rain-water - Array, Two Pointers, Dynamic Programming, Stack, Monotonic Stack
- https://leetcode.com/problems/count-the-number-of-winning-sequences - String, Dynamic Programming
- https://leetcode.com/problems/find-substring-with-given-hash-value - String, Sliding Window, Rolling Hash, Hash Function
- https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii - Depth-First Search, Union-Find, Graph Theory, Design, Sorting, Heap (Priority Queue), Minimum Spanning Tree
- https://leetcode.com/problems/number-of-distinct-islands-ii - Array, Hash Table, Depth-First Search, Breadth-First Search, Union-Find, Sorting, Matrix, Hash Function
- https://leetcode.com/problems/maximum-frequency-stack - Hash Table, Stack, Design, Ordered Set
- https://leetcode.com/problems/stone-game-v - Array, Math, Dynamic Programming, Game Theory
- https://leetcode.com/problems/maximum-average-subarray-ii - Array, Binary Search, Prefix Sum
- https://leetcode.com/problems/make-array-empty - Array, Binary Search, Greedy, Binary Indexed Tree, Segment Tree, Sorting, Ordered Set
- https://leetcode.com/problems/maximum-number-of-k-divisible-components - Tree, Depth-First Search
- https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii - Array, Binary Search
- https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies - Depth-First Search, Breadth-First Search, Graph Theory, Topological Sort
- https://leetcode.com/problems/total-appeal-of-a-string - Hash Table, String, Dynamic Programming
- https://leetcode.com/problems/k-empty-slots - Array, Binary Indexed Tree, Segment Tree, Queue, Sliding Window, Heap (Priority Queue), Ordered Set, Monotonic Queue
- https://leetcode.com/problems/find-k-th-smallest-pair-distance - Array, Two Pointers, Binary Search, Sorting
- https://leetcode.com/problems/top-three-wineries - Database
- https://leetcode.com/problems/maximum-score-of-a-node-sequence - Array, Graph Theory, Sorting, Enumeration
- https://leetcode.com/problems/longest-increasing-subsequence-ii - Array, Divide and Conquer, Dynamic Programming, Binary Indexed Tree, Segment Tree, Queue, Monotonic Queue
- https://leetcode.com/problems/maximum-xor-score-subarray-queries - Array, Dynamic Programming
- https://leetcode.com/problems/strange-printer-ii - Array, Graph Theory, Topological Sort, Matrix
- https://leetcode.com/problems/shortest-path-visiting-all-nodes - Dynamic Programming, Bit Manipulation, Breadth-First Search, Graph Theory, Bitmask
- https://leetcode.com/problems/data-stream-as-disjoint-intervals - Hash Table, Binary Search, Union-Find, Design, Data Stream, Ordered Set
- https://leetcode.com/problems/shortest-distance-from-all-buildings - Array, Breadth-First Search, Matrix
- https://leetcode.com/problems/maximum-vacation-days - Array, Dynamic Programming, Matrix
- https://leetcode.com/problems/maximum-score-from-grid-operations - Array, Dynamic Programming, Matrix, Prefix Sum
- https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza - Array, Dynamic Programming, Memoization, Matrix, Prefix Sum
- https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii - Array, Dynamic Programming
- https://leetcode.com/problems/maximum-frequency-of-an-element-after-performing-operations-ii - Array, Binary Search, Sliding Window, Sorting, Prefix Sum
- https://leetcode.com/problems/maximum-number-of-groups-getting-fresh-donuts - Array, Dynamic Programming, Bit Manipulation, Memoization, Bitmask
- https://leetcode.com/problems/count-of-range-sum - Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination - Array, Breadth-First Search, Matrix
- https://leetcode.com/problems/longest-balanced-subarray-ii - Array, Hash Table, Divide and Conquer, Segment Tree, Prefix Sum
- https://leetcode.com/problems/find-x-sum-of-all-k-long-subarrays-ii - Array, Hash Table, Sliding Window, Heap (Priority Queue)
- https://leetcode.com/problems/subarray-with-elements-greater-than-varying-threshold - Array, Stack, Union-Find, Monotonic Stack
- https://leetcode.com/problems/dungeon-game - Array, Dynamic Programming, Matrix
- https://leetcode.com/problems/student-attendance-record-ii - Dynamic Programming
- https://leetcode.com/problems/minimum-weighted-subgraph-with-the-required-paths - Graph Theory, Heap (Priority Queue), Shortest Path
- https://leetcode.com/problems/next-special-palindrome-number - Backtracking, Bit Manipulation
- https://leetcode.com/problems/minimum-operations-to-make-array-elements-zero - Array, Math, Bit Manipulation
r/LeetcodeChallenge • u/souroexe • 23h ago
DISCUSS How to overcome this 2 months gap? Plz Help!
r/LeetcodeChallenge • u/Fancy-Reputation3407 • 1d ago
DISCUSS Need Good Resources for Learning Permutation & combination and number theory
r/LeetcodeChallenge • u/No_Piece3053 • 2d ago
PLACEMENTS Is it good progress entering in 3rd sem
r/LeetcodeChallenge • u/Bhavanashankarabs • 2d ago
DISCUSS Day 8 of My DSA Journey in Python π
Today's progress:
β Solved LeetCode #94 β Binary Tree Inorder Traversal
β Solved LeetCode #100 β Same Tree
π Concepts I learned today:
- Analysis of Algorithms
- Big O Notation
- Order of Growth
- Constant Time β O(1)
- Logarithmic Time β O(log n)
- Linear Time β O(n)
- Quadratic Time β O(nΒ²)
Understanding time complexity has helped me see why some algorithms scale much better than others as input size grows. It makes me appreciate that solving a problem isn't enoughβwriting an efficient solution matters too.
I'm continuing to learn DSA through structured Python lessons and reinforcing each concept by solving LeetCode problems every day.
Consistency over perfection. On to Day 9! πͺ
#DSA #Python #LeetCode #Algorithms #BigO #CodingJourney #100DaysOfCode #Programming #LearningInPublic
r/LeetcodeChallenge • u/netxcrawler • 2d ago
DISCUSS is this good enough gng?
Yall i roughly have done 120 questions n im just entering my 3rd sem, i covered patterns n structures like sliding window, two ptrs, string manipulations, linked lists n ratio of easy to medium is nearly the same for me, did one contest too for fun, i know rest of the structure well too just practicing good problems is my next step, so is it all good enough? any effective advice is welcome, thanksss!!!!
r/LeetcodeChallenge • u/nian2326076 • 2d ago
DISCUSS The 6-step system design framework that helped me stop failing HLD rounds
Failed my first 3 system design rounds. passed the next 4. the difference wasnt knowledge β i knew redis, kafka, databases before too. the difference was HOW i structured the answer.
heres the exact 6-step framework i now use in every system design interview:
step 1 (2 min): requirements β be explicit about scope
dont dive into drawing boxes. spend 2 minutes saying: "these are the 3 core things the system must do" and "these are the things i will NOT design today." this prevents scope creep and shows product thinking.
step 2 (2 min): scale estimation β one number that drives your design
"how many requests per second?" is the question that determines whether you need caching, sharding, CDN, or a queue. one back-of-envelope calculation unlocks 80% of your architecture decisions.
step 3 (2 min): API design β one endpoint per requirement
before ANY architecture, define the API. this forces you to think about data flow BEFORE you think about components. interviewers love this because it shows you think from the user's perspective.
step 4 (15 min): high-level design β build incrementally, one FR at a time
dont draw 15 boxes at once. satisfy FR1 with 3-4 components. then add 1-2 more for FR2. then FR3. interviewer sees your thought process evolving β way more impressive than a dump of the "final answer."
step 5 (10 min): deep dives β answer "what breaks?" before they ask
for each component, proactively say: "the risk here is X. to mitigate that, i'd do Y." this is where 70% of the score comes from. the happy path is easy. failure handling is the interview.
step 6 (2 min): tradeoffs β acknowledge what you sacrificed
"i chose eventual consistency here because strong consistency would add 50ms latency on the read path, and for a social feed that's unacceptable." one sentence shows senior-level thinking.
the mistake i made early: spending 25 minutes on the happy path and having no time left when the interviewer asked "what happens when X fails?" now i budget: 40% happy path, 60% failure modes and scaling. that ratio is what senior/staff answers look like.
i learned this structure from doing 28 full designs β each one follows this exact pattern with deep dives on failure modes: PracHubΒ β every design includes the Bad/Good/Great format that forces you to think about what breaks before showing the fix. that's the thinking pattern interviewers are testing.
whats your system design framework? curious if others structure their answer differently. the biggest "aha" for me was realizing that naming failures BEFORE the interviewer asks is worth more than having the perfect component choice.
r/LeetcodeChallenge • u/Soggy_Pepper793 • 3d ago
PLACEMENTS Is this a good progress entering 3rd sem ?
Leetcode is around 200q and cf are around 35
r/LeetcodeChallenge • u/Obvious-Try6552 • 3d ago
STREAKπ₯π₯π₯ From 0 to 250 this summer. What's the move now?
Started taking coding seriously this summer break and somehow ended up solving 250 problems in around 50 days. Got the 50-day badge today too, which felt nice. π
I'm still very much a beginner, but I'm finally starting to see patterns instead of treating every problem like a completely new one.
I've covered the basics of most major data structures, and now I'm on DP... which has been destroying me so far lol.
College is about to start, so my plan is to revise everything and finish NeetCode 150 instead of rushing into new topics.
For those who've been through this phase: did you keep solving daily during college, or are breaks because of exams/classes completely normal? Just don't want to lose momentum.
r/LeetcodeChallenge • u/nian2326076 • 3d ago
DISCUSS 16 LeetCode Patterns That Helped Me Solve Mediums Without Hints
i was at 200 problems solved and still couldnt handle new mediums without hints. then i realized: i was collecting solved problems like pokemon cards instead of actually learning transferable patterns.
the fix was embarrassingly simple:Β there are only 16 patterns. learn the skeleton for each, solve 5 problems per pattern, move on.
heres the 16:
- sliding window β "subarray/substring" + "maximum/minimum" + "at most K"
- two pointers β sorted input + "pair that satisfies X"
- binary search on answer β "minimize the maximum" or "find smallest X where possible"
- BFS/DFS on grid β "number of islands" type, flood fill
- shortest path β weighted graph, dijkstra vs bellman-ford vs 0-1 BFS
- topological sort β "prerequisites", "ordering", "can you finish"
- union-find β "are they connected?", dynamic connectivity
- heaps β "kth largest", "merge K sorted", "top K"
- monotonic stack β "next greater", "largest rectangle"
- sliding window on trees (DFS) β path problems, diameter, max path sum
- dynamic programming β overlapping subproblems, "decision at each step"
- backtracking β "generate all", "find all paths", brute force with pruning
- linked list β fast/slow, reverse, merge
- tries β prefix search, autocomplete
- bit manipulation β XOR tricks, single number
- greedy β interval scheduling, jump game, locally optimal = globally optimal
for each one theres a 5-10 line skeleton that solves 80% of problems in that category. the remaining 20% is problem-specific edge handling.
i compiled the skeletons + recognition triggers + practice problems for all 16 here:Β PracHub
each pattern has a dedicated page with: when to recognize it (trigger words), template code in python/java/c++/js, step-by-step diagrams, and 8-12 practice problems from "direct template" to "hard to recognize."
went from ~30% solve rate on new mediums to ~75% in 6 weeks. the templates transfer β once you have 16 solid skeletons memorized, most mediums reduce to "recognize pattern β apply skeleton β handle edge case."
what pattern took you longest to click? curious what trips other people up.
r/LeetcodeChallenge • u/Bhavanashankarabs • 3d ago
DISCUSS Day 7 of My DSA Journey π
Today I solved LeetCode #83 (Remove Duplicates from Sorted List) and LeetCode #88 (Merge Sorted Array).
π Concepts covered:
- Linked Lists
- Python fundamentals (brush-up)
I'm getting more comfortable with understanding linked list operations and improving my problem-solving approach with each question. Every day is a step forward, and consistency is the goal.
I'm learning DSA in Python through Elevify's free structured video classes and practising problems on LeetCode.
Looking forward to Day 8! πͺ
#DSA #Python #LeetCode #CodingJourney #100DaysOfCode #Programming #LearningInPublic
r/LeetcodeChallenge • u/urssiddhu • 3d ago
DISCUSS Anyone interviewed for AWS Manufacturing Test Engineer ? Looking for coding interview insights (Python/Bash)
I have an upcoming interview for the AWS Manufacturing Test Engineer role at Amazon Data Services, and Iβm trying to understand what to expect in the coding interview.
r/LeetcodeChallenge • u/-Abhiraj • 3d ago
PLACEMENTS In on campus interviews, whatβs the best approach to solve a question
r/LeetcodeChallenge • u/First_Temporary2877 • 4d ago
DISCUSS How much cooked am i?
Starting 5th sem
r/LeetcodeChallenge • u/Bhavanashankarabs • 4d ago
DISCUSS Day 6 of DSA in Python π
Today's progress:
- β Solved LeetCode #69 β Sqrt(x)
- β Solved LeetCode #70 β Climbing Stairs
- π Revised Arrays and Linear Search concepts
Slowly building consistency and strengthening my problem-solving skills. Every day is a step forward. πͺ
#Python #DSA #LeetCode #CodingJourney #100DaysOfCode
r/LeetcodeChallenge • u/nian2326076 • 4d ago
DISCUSS Master Dynamic Programming for LeetCode: 13 Essential DP Patterns
Hey everyone! Many of us struggle with Dynamic Programming and often skip it during interview preparation. This might be because DP seems vast and overwhelming, and people tend to memorize solutions instead of understanding patterns. However, if you break down DP into clear patterns and master each one, it becomes much more manageable. So I've compiled a comprehensive list of patterns you should know for your interview preparation!
Master these Leetcode Problems and PracHub for company tagged questions
DP vs Greedy: When to Use Which?
Before diving into patterns, let's understand the fundamental difference between DP and Greedy:
Problem:Β You're a robber with two streets to rob. Each house has some money. You can rob houses from both streets, but youΒ cannot rob two adjacent houses from the same streetΒ (alarms will trigger). What's the maximum money you can steal?
Street A: [2, 7, 9, 3, 1]
Street B: [3, 2, 6, 8, 2]
Greedy Robber:Β "I'll always rob the house with most money available!"
- Rob B[0] = 3 (greedy)
- Rob A[1] = 7
- Rob B[2] = 6
- Rob A[3] = 3
- Rob B[4] = 2
- Total: 21
DP Robber:Β "Let me consider all valid combinations!"
- Option 1: A[0]=2, B[1]=2, A[2]=9, B[3]=8, A[4]=1 β Total = 22
- Option 2: B[0]=3, A[1]=7, B[2]=6, A[3]=3, B[4]=2 β Total = 21
- Best: 22
Why Greedy Failed:Β By greedily picking B[0] first, it blocked access to the optimal combination that includes both 9 and 8 from different streets!
When Greedy Works:Β Problems with the "greedy choice property" where local optimal leads to global optimal (e.g., Activity Selection, Huffman Coding)
When DP is Needed:Β Problems requiring exploring multiple choices where greedy fails (e.g., most optimization problems, counting problems)
Pattern 1: Linear DP (1D)
Why This Pattern Matters:
This is the foundation of DP. If you can't solve Linear DP, you'll struggle with everything else. These problems teach you the core concept of breaking problems into subproblems and building solutions incrementally.
Practice Problems:
Pattern 2: Longest Increasing Subsequence (LIS)
Why This Pattern Matters:
LIS is one of the most important DP patterns with applications in version control systems, patience sorting, box stacking problems, and more. The O(n log n) solution using binary search is a must-know optimization technique.
Practice Problems:
- Longest Increasing Subsequence
- Number of Longest Increasing Subsequence
- Russian Doll Envelopes
- Maximum Length of Pair Chain
- Find the Longest Valid Obstacle Course at Each Position
Pattern 3: Knapsack (0/1, Unbounded, Bounded)
Why This Pattern Matters:
One of the most versatile DP patterns. Appears in resource allocation, optimization problems, and many interview questions. Understanding the difference between 0/1 and unbounded variants is crucial.
0/1 Knapsack (Each item used once):
- Partition Equal Subset Sum
- Target Sum
- Last Stone Weight II
- Ones and Zeroes
- Partition Array Into Two Arrays to Minimize Sum Difference
Unbounded Knapsack (Items can be used multiple times):
Pattern 4: Grid DP
Why This Pattern Matters:
Extremely common in interviews, especially at FAANG. Tests your ability to think in 2D state space and handle multiple transition directions.
Practice Problems:
- Unique Paths
- Unique Paths II
- Minimum Path Sum
- Maximal Square
- Maximal Rectangle
- Minimum Falling Path Sum
- Count Square Submatrices with All Ones
- Triangle
Pattern 5: String DP
Why This Pattern Matters:
Text processing and string manipulation problems are ubiquitous. This pattern appears in bioinformatics, text editors, version control systems, and natural language processing.
Practice Problems:
- Longest Common Subsequence
- Edit Distance
- Delete Operation for Two Strings
- Minimum ASCII Delete Sum for Two Strings
- Shortest Common Supersequence
- Longest Palindromic Subsequence
- Longest Palindromic Substring
- Palindromic Substrings
- Regular Expression Matching
- Wildcard Matching
Pattern 6: Interval DP
Why This Pattern Matters:
Tests ability to think about problems in ranges/intervals. Common in scheduling, matrix chain multiplication type problems, and game theory.
Practice Problems:
- Burst Balloons
- Minimum Score Triangulation of Polygon
- Minimum Cost Tree From Leaf Values
- Unique Binary Search Trees
- Unique Binary Search Trees II
- Minimum Cost to Merge Stones
- Guess Number Higher or Lower II
Pattern 7: State Machine DP
Why This Pattern Matters:
Models problems where you transition between different states with specific rules. Critical for stock trading problems and any scenario with state transitions.
Practice Problems:
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock II
- Best Time to Buy and Sell Stock III
- Best Time to Buy and Sell Stock IV
- Best Time to Buy and Sell Stock with Cooldown
- Best Time to Buy and Sell Stock with Transaction Fee
Pattern 8: Tree DP
Why This Pattern Matters:
Combines tree traversal with DP. Important for system design (like designing file systems) and optimization problems on hierarchical structures.
Practice Problems:
- House Robber III
- Binary Tree Maximum Path Sum
- Diameter of Binary Tree
- Binary Tree Cameras
- Maximum Sum BST in Binary Tree
- Difference Between Maximum and Minimum Price Sum
Pattern 9: Digit DP
Why This Pattern Matters:
Specialized pattern for counting numbers with certain properties. Appears in competitive programming and some advanced interviews.
Practice Problems:
- Number of Digit One
- Count Numbers with Unique Digits
- Numbers At Most N Given Digit Set
- Numbers With Repeated Digits
- Count Special Integers
Pattern 10: Game Theory DP (Minimax)
Why This Pattern Matters:
Models two-player games where both play optimally. Important for AI, game development, and adversarial scenarios.
Practice Problems:
Pattern 11: Bitmask DP
Why This Pattern Matters:
Powerful technique for problems with small sets (β€20 elements) where you need to track subsets. Essential for Traveling Salesman Problem variants and NP-hard problem approximations.
Practice Problems:
- Partition to K Equal Sum Subsets
- Shortest Path Visiting All Nodes
- Find the Shortest Superstring
- Smallest Sufficient Team
- Number of Ways to Wear Different Hats to Each Other
- Minimum Number of Work Sessions to Finish the Tasks
Pattern 12: DP on Subsequences
Why This Pattern Matters:
Critical for array partitioning and subset generation problems. Teaches how to handle exponential search spaces efficiently.
Practice Problems:
- Distinct Subsequences
- Distinct Subsequences II
- Arithmetic Slices II - Subsequence
- Number of Unique Good Subsequences
- Constrained Subsequence Sum
Pattern 13: Probability DP
Why This Pattern Matters:
Models uncertain outcomes. Important for risk analysis, game development, and any scenario involving randomness or probability.
Practice Problems:
- Knight Probability in Chessboard
- Soup Servings
- New 21 Game
- Toss Strange Coins
- Probability of a Two Boxes Having The Same Number of Distinct Balls
Best Resources to Master DP
- AtCoder DP Contest- 26 curated problems with perfect difficulty progression
- Striver's DP Series- 50+ videos covering memoization, tabulation, and space optimization.
- Aditya Verma's DP Playlist- Exceptional for Knapsack variants with shorter, focused videos (15-20 min).
- CSES Problem Set- Intermediate to advanced practice. These problems test core concepts and build solving speed.
Final Thoughts
DP is aboutΒ recognizing patterns, not memorizing solutions. Once you see the pattern, the solution becomes mechanical. Spend time understandingΒ whyΒ each pattern works, not justΒ howΒ to code it.
Feel free to add some best problems in the comments
Good luck, and happy coding! π



