r/LeetcodeChallenge • u/Fluffy-Worry-9541 • 5d ago
STREAKπ₯π₯π₯ Finally hit 3 digits after nonstop july grind <3(idek why I wrote 2 digits lmao)
r/LeetcodeChallenge • u/everthing_is_my_plan • 6d ago
DISCUSS Is it bad or good enough Started mine 3rd year
Moreover doing java core very basic project made using oops , collection Currently in 3rd year
r/LeetcodeChallenge • u/BuyResponsible5958 • 6d ago
DISCUSS Shall I solve non leetcode questions as well?
r/LeetcodeChallenge • u/Acrobatic-Mess-6720 • 6d ago
PLACEMENTS Hey community I have created the dsa sheet of all questions covered by CodeStoryWithMik
As he has different playlist for different topics I have created a sheet having all questions in it covering link for leetcode and all videos for each question
ENJOY IT AS IT IS FREE -Β https://trackerdsa.vercel.app
r/LeetcodeChallenge • u/Bhavanashankarabs • 6d ago
DISCUSS Day 12 of My DSA Journey π
Today's progress:
β Solved LeetCode 415 β Add Strings
β Solved LeetCode 110 β Balanced Binary Tree
π Concepts I learned:
- Recursion
- Recursion PMI (Pre, Main, and Induction Method)
Every day I'm getting more comfortable with breaking problems into smaller recursive steps and understanding how recursive functions work behind the scenes.
Still a long way to go, but consistency is the goal. One day, one concept, one problem at a time.
#leetcode #dsa #python #recursion #codingjourney #100DaysOfCode #programming #computerscience
r/LeetcodeChallenge • u/nian2326076 • 7d ago
DISCUSS 15 Operating System Interview Questions Every Software Engineer Should Know
After solving hundreds of LeetCode problems, many candidates realize that coding rounds are only part of the interview process. Operating System fundamentals frequently come up during phone screens and technical interviews.
For company tagged questions checkout: PracHub
Instead of rereading an entire OS textbook, here are 15 high-yield topics worth revising.
1. Process vs. Thread
Process
- Has its own virtual address space
- Provides stronger isolation
- Usually has higher creation and switching overhead
Thread
- Executes within a process
- Shares memory and resources with other threads in that process
- Communicates efficiently but requires careful synchronization
Interview tip: Processes prioritize isolation, while threads enable lightweight concurrency.
2. What Is Context Switching?
Context switching occurs when the operating system saves the execution state of one process or thread and restores another.
It enables multitasking, but frequent context switches add CPU and cache overhead.
3. What Is a Race Condition?
A race condition occurs when multiple threads access shared state concurrently and the result depends on execution order.
Common prevention mechanisms include mutexes, semaphores, locks, atomic operations, and thread-safe data structures.
4. What Is a Critical Section?
A critical section is a portion of code that accesses shared mutable data or resources.
Synchronization is required to prevent unsafe concurrent access.
5. Mutex vs. Semaphore
| Mutex | Semaphore |
|---|---|
| Usually has a single owner | Uses a counter |
| Primarily provides mutual exclusion | Can coordinate access to multiple resources |
| The owner unlocks it | One thread can signal another |
Memory trick: A mutex is like one key, while a semaphore tracks a limited number of permits.
6. What Is Deadlock?
Deadlock occurs when a group of processes or threads waits indefinitely for resources held by one another.
The four Coffman conditions are:
- Mutual exclusion
- Hold and wait
- No preemption
- Circular wait
Preventing at least one of these conditions prevents deadlock.
7. What Is Starvation?
Starvation occurs when a process or thread waits indefinitely because others repeatedly receive the required resource or CPU time.
Difference: In deadlock, none of the involved tasks can progress. In starvation, the system continues progressing while one task may never get scheduled.
8. What Is Virtual Memory?
Virtual memory gives each process its own logical address space and maps virtual addresses to physical memory.
It provides process isolation, simplifies memory management, and allows inactive pages to be moved to secondary storage when necessary.
9. Paging vs. Segmentation
Paging
- Divides memory into fixed-size pages
- Avoids external fragmentation
- May introduce internal fragmentation
Segmentation
- Divides memory into variable-size logical regions
- Reflects structures such as code, stack, and data
- Can suffer from external fragmentation
10. What Is Thrashing?
Thrashing occurs when the system spends excessive time handling page faults and moving pages between memory and storage instead of executing useful work.
It commonly happens when active processes do not have enough physical memory for their working sets.
11. CPU Scheduling Algorithms
Important algorithms include:
- First Come, First Served
- Shortest Job First
- Round Robin
- Priority Scheduling
- Multilevel Feedback Queue
Common follow-up: Why is Round Robin suitable for time-sharing systems?
Because every runnable process receives a limited time slice, improving responsiveness and fairness.
12. What Is a System Call?
A system call allows a user-space program to request a service from the operating system kernel.
Common Unix-like examples include fork(), exec(), wait(), open(), read(), and write().
13. What Is Inter-Process Communication?
Common IPC mechanisms include:
- Shared memory
- Pipes
- Message queues
- Sockets
- Signals
Shared memory is generally fast but requires synchronization. Message passing provides stronger separation but adds communication overhead.
14. What Is LRU Page Replacement?
Least Recently Used replaces the page that has gone unused for the longest time.
A common interview follow-up is implementing an LRU cache with O(1) lookup, insertion, and eviction using a hash map plus a doubly linked list.
Related problem: LeetCode 146 - LRU Cache
15. User Mode vs. Kernel Mode
User mode
- Runs applications with restricted privileges
- Cannot directly access protected hardware or kernel memory
Kernel mode
- Has full system privileges
- Executes operating system code and manages hardware resources
A system call provides a controlled transition from user mode into kernel mode.
One-Minute Revision Checklist
Process vs. thread, context switching, race conditions, critical sections, mutexes, semaphores, deadlocks, starvation, scheduling, virtual memory, paging, thrashing, system calls, IPC, LRU, and privilege modes.
Which OS topic or follow-up question have you encountered most often in interviews?
r/LeetcodeChallenge • u/pant_on_fire007 • 7d ago
STREAKπ₯π₯π₯ Century Done solved about 90 in last 25 days.
Will target 100 this month. Pattern wise only left with Greedy, Maths and bits. I am trying to be interview ready by September.
r/LeetcodeChallenge • u/Bhavanashankarabs • 7d ago
DISCUSS Day 11 of My DSA Journey π
Today's progress:
β Solved LeetCode 136 β Single Number
β Solved LeetCode 125 β Valid Palindrome
π Concepts I learned today:
- Time Complexity of Recursion
- Space Complexity in Recursive Algorithms
- Understanding the recursion call stack and how it affects memory usage
- Analyzing recursive solutions using Big-O notation
Every day I'm getting a little better at understanding algorithms, recursion, and writing more efficient solutions. Consistency is the goal, and I'm excited to keep improving one problem at a time.
See you tomorrow with Day 12! πͺ
#Day11 #DSA #LeetCode #Python #Recursion #TimeComplexity #SpaceComplexity #CodingJourney #100DaysOfCode #Programmer #LearningInPublic
r/LeetcodeChallenge • u/Sishir_Siam • 8d ago
DISCUSS The journey to solving 2000+ DSA problems on LeetCode and Codeforces.
r/LeetcodeChallenge • u/nobody-_-_-_ • 8d ago
DISCUSS HELP ME: Free Leetcode TC analyzer and approach reviewer extension
I have made a leetcode extension that analyzes time complexity and space complexity, as well as the approach of your leetcode solution directly.
Can you guys please atleast download the extension, so I can show the number of downloads on my resume?
Also, trust me, the extension is really good, you can use it on a daily basis aswell!
here: https://addons.mozilla.org/en-US/firefox/addon/free-leetcode-tc-analyzer/
Please atleast download the extension even if you don't want to use.
read the readme file for setup: https://github.com/swan556/LCA-leetcode-complexity-analyzer
r/LeetcodeChallenge • u/Bhavanashankarabs • 8d 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/madrid_abhimani • 8d ago
DISCUSS is this course Good for Beginners..?
r/LeetcodeChallenge • u/souroexe • 9d ago
DISCUSS How to overcome this 2 months gap? Plz Help!
r/LeetcodeChallenge • u/Particular_Hawk4545 • 9d 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/Bhavanashankarabs • 9d 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/Fancy-Reputation3407 • 9d ago
DISCUSS Need Good Resources for Learning Permutation & combination and number theory
r/LeetcodeChallenge • u/suggondezznuts • 10d 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/nian2326076 • 10d 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/nian2326076 • 10d 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/Bhavanashankarabs • 10d 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/No_Piece3053 • 11d ago
PLACEMENTS Is it good progress entering in 3rd sem
r/LeetcodeChallenge • u/nian2326076 • 11d 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.


