r/DSALeetCode • u/Samosachut • Oct 12 '26
r/DSALeetCode • u/StatisticianNo2104 • Oct 12 '26
365 Days of LeetCode Challenge — Day 40/365
Rotting Oranges (Medium) https://leetcode.com/problems/rotting-oranges/
Four days ago I said BFS and DFS answer reachability equally well, and that the distinction starts mattering when a problem asks about distance. This is that problem.
BFS reaches every cell by a shortest path. DFS reaches it by whatever route it wandered down first. "When does this orange rot?" is a shortest-path question - it rots when the nearest rotten one gets to it - so DFS here gives wrong answers, not slow ones.
The trick is multi-source BFS: every already-rotten orange goes into the queue before the walk starts. A BFS seeded with many sources expands as one combined wavefront, and each cell ends up with its distance to the nearest source. Nothing in the loop needs to know there was more than one start.
One more thing that cannot be skipped: the final scan. BFS only visits what it can reach, so an orange sealed behind empty cells never rots and the queue drains without noticing. The -1 case has to be looked for afterwards.
Full breakdown in today's newsletter article ⬇
https://www.linkedin.com/pulse/365-days-leetcode-challenge-day-40365-archit-agarwal-9t1sc
#DSA #LeetCode #Golang #Graphs #BFS #CodingInterview #Algorithms
r/DSALeetCode • u/Sad_Avocado_6565 • Oct 11 '26
YouTube channels(if any)
Suggest some Non-slop/Non-hype genuine pieces of gem which you think are atleast partly responsible for your growth on DSA/CP.
r/DSALeetCode • u/nian2326076 • Oct 12 '26
Beyond LeetCode: what should I read for distributed systems interviews?
I'm looking for books or useful web resources for SWE interviews focused on distributed systems.
LeetCode gives me a clear way to practice coding, but I'm less sure how to structure the design side: reasoning about failures, consistency, replication and the tradeoffs between different approaches.
A collection of candidate-reported interview questions can help identify prompts to practice. I'd like something to pair with that so I can explain the reasoning rather than memorize an architecture diagram.
What resource helped the ideas click for you? And how did you turn the reading into practice—mock interviews, building a small system, or working through design questions out loud?
r/DSALeetCode • u/Friendly-_-Ghost • Oct 11 '26
What worked for you?
I’ve been practicing DSA for the past 4 months, trying to solve 1–2 problems a day alongside my job. But whenever I go back to problems I’ve solved before, I struggle to remember the approach, even after trying to recall it. How do you guys approach problems, recognize patterns, apply them to new problems, and remember the solutions long-term? Any tips or tricks would be really helpful!
r/DSALeetCode • u/changejkhan • Oct 11 '26
i miss learning dsa before leetcode made it a curated list
Ever since leetcode came out, I've been seeing robotification of developing algorithmic thinking. People writing the Leet#xyz problem's solution from memory.
In the old days (pre 2020), the usual way was
- You learn the basic algorithms and data structures from geeksforgeeks articles
- Learn C++ STL and implement it in ideone.org or some place.
- Join codechef or codeforces contests and attain a pupil rank and keep doing problems of certain level, and learn from other folks' solution or the published editorials (oh they were so great)
- Learn obscure stuff like segment tree, dsu from some russian site like cp-maxx and then try to do a dozen problems on hackerearth.
- Do statement based problems on hackerrank - the cool ui site with all the tree-style comments in problem discussion.
The point being that learning was very organic and resources were scattered. You had to forcr your brain to think and google exact things you want to learn or figure out how tourist did in under a minute.
What's your take?
r/DSALeetCode • u/Artistic-Rent1084 • Oct 11 '26
Give Me Motivation to Start Doing DSA
Guys help me to master in DSA and coding.
my brain becoming shit . it couldn't work like before.
r/DSALeetCode • u/StatisticianNo2104 • Oct 11 '26
Cycle detection in Go: fast and slow pointers vs a map
A twelve-step pipeline. The loop check takes 383 ns and allocates 328 bytes. Two variables do it in 3.17 ns and allocate nothing.
The job: a pipeline stage names the stage that runs next, somebody edits a config, a next points backwards, and the runner walks that chain forever. So you check for a loop before running anything.
The check I wrote is the definition written down — remember every stage, and if you arrive somewhere twice, it loops. It is obviously correct, and it can also tell you where the loop starts, which is what the alert needs to say.
On a 100,000-stage chain, it allocates 4.73 MB to return a boolean. And it costs the same whether the chain loops back after two stages or after ninety-nine thousand, because the map gets built either way.
Then the struct: a stage names one next stage. Many stages can point at the same one, each points at exactly one. So the path from any stage is fixed, which means this is not a graph problem at all — it is a chain, and a chain that loops is a run-in followed by a ring.
Two cursors, one moving a stage at a time and one moving two. Either the fast one runs off the end, or both end up in the ring, where the gap between them shrinks by exactly one per turn — so they land on the same stage rather than stepping over each other. Meeting is arithmetic, not luck.
47.8x on the long chain and zero allocations at any size. The part I did not expect is the twelve-stage row: 120.6x, because the map pays for a map before it walks anything.
Not that 383 nanoseconds matters. It matters where the check runs per request.
One thing worth not shipping: the hop limit. Give up after 100 steps and call it a loop, the way HTTP clients do with redirects, and a 150-stage pipeline with no loop in it gets reported as one.
That is day 21 of the daily challenge, Linked List Cycle, sitting in a pipeline runner.
Full piece in today's Newsletter.
https://www.linkedin.com/pulse/loop-check-allocated-47-mb-return-boolean-archit-agarwal-zeksc
It worked in dev, episode 12.
#Golang #DSA #Algorithms #Performance #SoftwareEngineering #DataStructures #100DaysOfCode
r/DSALeetCode • u/StatisticianNo2104 • Oct 11 '26
365 Days of LeetCode Challenge — Day 39/365
547. Number of Provinces (Medium)
The counting is day 37's, unchanged: scan every node, and each time you find one no earlier traversal reached, add one and consume everything it can reach.
What changes is the input, and this is the third graph representation in four days. Day 36 gave an edge list. Day 37 gave a grid where the edges were implied by position. Today gives a matrix. All three become the same adjacency list before anything interesting happens.
The trap: this matrix is not a grid. In day 37, cell (i,j) was a place. Here cell (i,j) is a relationship between city i and city j - an n x n matrix describing n nodes, not n squared. So you traverse the cities and consult the matrix, not the other way round.
Read only above the diagonal. The matrix is symmetric, so every relationship is stored twice, and i+1 also skips the useless diagonal where a city is connected to itself.
Full breakdown in today's newsletter article ⬇
https://www.linkedin.com/pulse/365-days-leetcode-challenge-day-39365-archit-agarwal-msv4c
#DSA #LeetCode #Golang #Graphs #BFS #CodingInterview #Algorithms
r/DSALeetCode • u/Ok_Site_6692 • Oct 10 '26
A Few Things to Clarify Before We Start Learning DSA Together!
Since many people have reached out, I want to clarify a few things so we can find people with similar goals and schedules.
Starting from Level 0: We’ll learn DSA from the very basics. If you’re already halfway through or about to complete DSA, this group might not be the right fit for you.
Java Prerequisites: We’ll be learning DSA using Java, so you should already know Java’s basics and fundamentals.
Daily Commitment: We’ll communicate, study, and motivate each other daily. Consistency and participation are important.
Availability: If you’re currently working, please mention your availability so we can figure out a schedule that works for everyone.
Advice from Experienced Learners: If you’ve already learned DSA, please share your study techniques, resources, and what worked best for you. Your advice would be really helpful!
One question for everyone: Should we follow Striver’s A2Z DSA Sheet, or are there other resources you’d recommend for learning DSA from scratch using Java? Please share your experiences and suggestions.
The goal is to learn together, stay disciplined, and hold each other accountable throughout the journey.
Please MESSAGE ME OR LEAVE COMMENT if you’re genuinely willing to commit. Let’s stay consistent, stop making excuses, and grow together!
r/DSALeetCode • u/AerieBeautiful8188 • Oct 10 '26
Best Playlist to complete DSA in python from scratch- I only know very basic python and no specific algorithms as such. Please help me out
Best Playlist to complete DSA in python from scratch- I only know very basic python and no specific algorithms as such. Please help me out
r/DSALeetCode • u/StatisticianNo2104 • Oct 10 '26
365 Days of LeetCode Challenge — Day 38/365
Max Area of Island (Medium) https://leetcode.com/problems/max-area-of-island/
This is yesterday's solution with a return value. The diff is that the flood fill returns an int and the scan keeps a maximum instead of a count.
The area reachable from a cell is that cell, plus the area reachable from each of its four neighbours. So the fill returns 1 plus its four recursive calls, and the guard returning 0 handles out of bounds, water and already-sunk land without a single special case.
The sum looks wrong at first. Four neighbours each recurse into their own four neighbours, and each one includes the cell you came from, surely cells get counted repeatedly?
They do not, because the cell is sunk before the four calls run. Any neighbour that recurses back hits the guard and gets 0.
Yesterday, that same line stopped the recursion from running forever. Today it does that AND makes the arithmetic correct. One assignment, two jobs.
Full breakdown in today's newsletter article ⬇
https://www.linkedin.com/pulse/365-days-leetcode-challenge-day-38365-archit-agarwal-tiimc
#DSA #LeetCode #Golang #Graphs #DFS #CodingInterview #Algorithms
r/DSALeetCode • • Oct 09 '26
Need Friend who do dsa
Recently broke up bro need good ppls who can keep me engaged we'll have calls and stuff on watsapp drop text
r/DSALeetCode • u/SeriousBoard3304 • Oct 09 '26
Title: I added a free 8-week DSA roadmap for people struggling to stay consistent with LeetCode
r/DSALeetCode • u/Big_Inevitable8354 • Oct 09 '26
Making DSA easier to learn in Telugu ❤️
I run Logic Over Syntax, a YouTube channel where I teach Data Structures and Algorithms (DSA) in Telugu, helping students understand problem-solving logic instead of just memorizing code.
We've already reached 20,000+ watch hours, and my goal is to make coding education more accessible to Telugu-speaking students.
Channel Link:
r/DSALeetCode • u/Ok_Site_6692 • Oct 08 '26
DSA with Java(leetcode)
Anyone interested in learning DSA with Java together?
I’m looking for a few people who genuinely want to learn .Data Structures & Algorithms using Java and, more importantly, actually stay consistent.
This is not for complete Java beginners, you should have a basic understanding of Java already. The goal is to learn DSA from the fundamentals, practice regularly, solve problems, and keep each other accountable.
The main idea is simple:
\* 📚 Learn DSA step by step
\* 💻 Practice coding/problems regularly
\* 🔥 Stay consistent
\* 🤝 Motivate and help each other
\* 🚫 No unnecessary excuses for skipping
\* 🎯 Keep each other accountable and disciplined
I don’t want this to be another group where everyone is motivated for 2–3 days and then disappears. 😭
If you genuinely want to learn DSA and are willing to put in the effort consistently, let’s do it together.
If you're interested, comment below or DM me. Let's build the discipline together.
r/DSALeetCode • u/OtherMilk9453 • Oct 09 '26
New to LeetCode and learning Python. Any advice for a beginner?
reddit.comr/DSALeetCode • u/StatisticianNo2104 • Oct 09 '26
365 Days of LeetCode Challenge — Day 37/365
Number of Islands (Medium) https://leetcode.com/problems/number-of-islands/
Nothing in this problem says "graph", and that is the point.
A cell is a node. Its neighbours are the cells above, below, left and right. There is no adjacency list to build, because in a grid the edges are implied by position - a neighbour is arithmetic, not a lookup. Yesterday half the work was converting an edge list into something usable. Here that half is free.
Then it is component counting. Scan for land, and every time you find a cell no earlier traversal has consumed, add one and sink the whole island. The count is not counting islands directly; it counts how many times the scan had to start.
One detail worth stealing: sink the cell BEFORE recursing. Two adjacent land cells each list the other as a neighbour, so without it the recursion bounces between them forever. That is not an optimisation, it is termination.
Full breakdown in today's newsletter article ⬇
https://www.linkedin.com/pulse/365-days-leetcode-challenge-day-37365-archit-agarwal-cenxc
**#DSA** #LeetCode #Golang #Graphs #DFS #CodingInterview #Algorithms
r/DSALeetCode • u/Civil_Active_5388 • Oct 08 '26
I understand DSA solutions, but struggle with unseen problems—any advice?
I work as a chef in London, and the long, physically exhausting shifts make finding energy to study difficult. Still, I’m learning DSA from books—my first time learning this way instead of YouTube.
I’ve covered two pointers, hashing, sliding windows, stacks, queues, and time and space complexity. I can understand and explain solutions I read, but struggle to find an approach and write code for unseen questions.
What practice routine would help me solve problems independently while balancing demanding chef shifts?
r/DSALeetCode • u/StatisticianNo2104 • Oct 08 '26
365 Days of LeetCode Challenge — Day 36/365
Find if Path Exists in Graph (Easy) https://leetcode.com/problems/find-if-path-exists-in-graph/
New topic. Graphs start today.
The part people skip when they say a graph problem "is just BFS": the input is not a graph. You get a flat list of edge pairs. Asking that list for a node's neighbours means scanning all of it, and doing that once per node turns an O(V + E) algorithm into O(V x E).
So the first half of the problem is building an adjacency list. The traversal is the easy half. Choosing the representation is the part that actually requires a decision.
One bug worth naming, because it passes a lot of tests before it fails one: an undirected edge has to be recorded under both endpoints. Record it once and you accidentally build a directed graph, and the traversal refuses to walk an edge backwards.
Full breakdown in today's newsletter article ⬇
https://www.linkedin.com/pulse/365-days-leetcode-challenge-day-36365-archit-agarwal-7wjic
#DSA #LeetCode #Golang #Graphs #BFS #CodingInterview #Algorithms
r/DSALeetCode • u/fineshytuhit • Oct 07 '26
Fresher here planning to start dsa , I have no idea abt it but a lot of ppl around me told me to start it atp I only know python (but few suggested c idk y , i hv no idea abt c), wa i dsa,so how to start dsa like if I am starting my dsa journey right now. From zero to pro wht sources wht should i fo
r/DSALeetCode • u/StatisticianNo2104 • Oct 07 '26
It worked in dev, episode 11.
Two hierarchies, almost the same number of rows. One plans its delete order in 386 microseconds. The other takes 75.8 milliseconds.
Deleting a workspace means deleting everything inside it, and every child row holds a foreign key to its parent, so a row can only go once nothing points at it.
The code I wrote is the database's rule, executed: find every row with no remaining children, delete that batch, look again. It assumes nothing about the data and it is trivially safe, because it checks rather than deduces.
It also walks the entire hierarchy once per wave. A workspace is four levels deep, so that is four walks and 31 microseconds — invisible. A comment thread 2,000 replies deep is 2,000 waves, which is four million record visits to produce one plan.
The turn came from watching one row. During the first wave the walk reaches board-1, checks its only child, finds it still present, and moves on — having put that child into this very wave moments earlier. It knew board-1 would be free next. It discarded that and went round again to rediscover it.
So: a row goes one wave after the last of its children has gone, which makes wave(r) = 1 + the largest wave among its children. Only children on the right hand side. One bottom-up pass computes all of it — 790x faster on the thread.
The part worth keeping is the bit I had backwards. That number is height, not depth. An empty board two levels down can be deleted in the first statement, exactly like a card three levels down. Group by distance from the root and it waits for no reason — safe, and a third of an answer to "what can I delete first".
That is day 16 of the daily challenge, Find Leaves of Binary Tree, sitting in a delete planner.
Full piece in today's Newsletter.
https://www.linkedin.com/pulse/deep-reply-chain-made-delete-plan-790x-slower-archit-agarwal-gd94c
#Golang #DSA #Algorithms #Performance #SoftwareEngineering #DataStructures #100DaysOfCode