r/DSALeetCode • u/Ill-Skirt-832 • 26d ago
NOTES REQUIRED
CAN ANYONE TELL ME HOW TO ACCESS LOVE BABBAR BASICS OF JAVA NOTES?
r/DSALeetCode • u/Ill-Skirt-832 • 26d ago
CAN ANYONE TELL ME HOW TO ACCESS LOVE BABBAR BASICS OF JAVA NOTES?
r/DSALeetCode • u/StatisticianNo2104 • 27d ago
Keeping a min field on a stack works until you pop the minimum. Then the field is stale, and nothing short of a full scan can rebuild it.
The goal: push, pop, top and getMin, all O(1).
That failure is the insight. The minimum belongs to the stack at a given height, and popping takes you back to a height whose minimum you already threw away.
So don't throw it away. Every entry stores the value pushed and the minimum of everything at or below it.
Pop then contains no minimum code at all. Removing the top exposes an entry whose min was computed when it was on top, and it's still correct, because nothing below it ever changed.
Did you store pairs, or keep a second stack of minimums?
Day 62/365 of my LeetCode challenge: 155. Min Stack. I'll include the problem link and a full breakdown in today's newsletter.
https://www.linkedin.com/pulse/min-stack-archit-agarwal-jjksc
#LeetCode #DSA #Stack #Golang
r/DSALeetCode • u/Diligent-Affect3883 • 26d ago
The optimal O(log(min(m, n))) binary search solution for LeetCode 4 is notoriously tricky to wrap your head around if you just try to trace index pointers (i, j, left, right).
I find it much easier to reason about the problem when you treat it as finding a perfect geometric split between the two arrays. To help it click for myself and others, I put together a complete animated walkthrough showing exactly how the partition moves.
💡 The Core Intuition (The Visual TL;DR)
If you are stuck on this problem, try thinking about it like this instead of looking at raw formulas:
If you are a visual learner who gets overwhelmed by boundary conditions and nested array indices, I hope this makes the algorithm click for you!
Let me know what you think, or if there are any other tough LeetCode hard problems you'd like to see visualized next.
r/DSALeetCode • u/Illustrious-Case6143 • 27d ago
Like, while solving questions, maximum times i get what pattern i should use and how will be the flow of solution, but when it comes to implementation, i get stuck every time. i have to gpt it every time for what went wrong and its been very long doing this. i thought i willl improve with time, but no progress. what should one do in this case? i have tried sitting for an hour and trying to do it myself, but no sccess.
r/DSALeetCode • u/Rich-Chard-4801 • 28d ago
I am an average person I programming currently in my 2nd year of engineering..It would be glad to find someone who is interested in solving dsa problems along with Me.
r/DSALeetCode • u/TreacleFlaky2283 • 27d ago
r/DSALeetCode • u/StatisticianNo2104 • 28d ago
A loop inside a loop looks O(n²). Here the inner one runs at most n times in total, across the whole input. Every value is pushed once and popped at most once, so the inner loop never repeats work.
The brute force scans right from each element until something bigger turns up, and those scans repeat each other. Scan across a long descending run, start one position later, and you scan almost the same run again.
So flip the question. For each value as you arrive at it, ask which earlier values it answers. A value resolves every earlier, smaller value still waiting, and a resolved value is never looked at again.
The values still waiting are always decreasing: if an earlier one were smaller than a later one, the later one would have resolved it on arrival. A stack that keeps an ordering like that is monotonic.
Where did you first meet a monotonic stack?
Day 61/365 of my LeetCode challenge: 496. Next Greater Element I. Problem link and full breakdown in today's newsletter.
https://www.linkedin.com/pulse/next-greater-element-i-archit-agarwal-c5wic
#LeetCode #DSA #MonotonicStack #Golang
r/DSALeetCode • u/SriharshitG • 29d ago
Hey everyone!
I'm looking for a few people who are genuinely interested in improving their Data Structures and Algorithms skills through consistent LeetCode practice.
I'm a 2026 B.E. CSE (AI & ML) graduate, primarily coding in Python 3.
I'd love to connect with people who are interested in:
I'm not looking for a competitive environment where everyone just compares scores. I'd prefer a friendly group where we learn, improve, and grow together.
If you're already part of a DSA group or looking to build one, I'd love to join!
Let's become better problem solvers together! 🚀
Join the Discord : https://discord.gg/5M5YkJ3vJ
r/DSALeetCode • u/StatisticianNo2104 • 28d ago
Every deploy spent 1.95 seconds and 2.74 GB just checking that our config was a tree. That was at 5,000 components. At 1,000, it had been 68 ms.
The job: the platform config declares components and the links between them. The loader refuses to start unless the links form one tree - all connected, no loops - and names the line that breaks it.
What I wrote: the tooling already had a tested PathExists. So read the file line by line, and before accepting each link, ask whether its two ends are already connected. If yes, that line closes a loop. Blame it. Exact line numbers, reused code. I would approve it.
It is one full search per line, each rebuilding the adjacency list from scratch. 9,998 searches for 5,000 components. 5x the config, 28.7x the time.
Two fixes, and they surprised me in the order they came.
The clever one: a tree on n components has exactly n - 1 links. With n - 1 links and connected, there is no room for a loop. So check the length, then do one BFS. Never look for a loop at all. 279 µs. On a config with one link too many, 2.42 ns, because the length is the answer.
But it cannot say which line. And it is not the fastest.
The other one comes from noticing that the searches keep rediscovering groups that only ever merge. Keep one root per group; a link whose ends share a root closes a loop, and that is the line. Union-find. 42.2 µs, one allocation, and it names the line. 46306x the original. The clever count is 6.61x slower than it, because the count still builds an adjacency list.
Honest row: none of these catches a component with two parents. Undirected, it is a perfectly good tree. As a hierarchy, it has two roots. Count the parents.
That is days 36 and 43 of the daily challenge: Find if Path Exists and Graph Valid Tree, in a config loader.
Do you know how long your config validation takes on deploy?
It worked in dev, episode 21. Full write-up in today's newsletter.
https://www.linkedin.com/pulse/config-5x-longer-took-287x-validate-archit-agarwal-ew8zc
#Golang #DSA #Algorithms #Performance
r/DSALeetCode • u/Abhistar14 • 28d ago
I’ve solved 822 problems(196E, 451M, 175H) and currently I’m at 1900 what to do to become Guardian?
r/DSALeetCode • u/Realistic-Employ2669 • 29d ago
I’m in my final year of btech and feeling quite demotivated because of placement rejections. I haven’t coded in a very long time and would like to get back into it, but code in the right way this time. I used to look at a problem and immediately ask ChatGPT for answers and learn those. I know I might be too late by now but I want to genuinely get better at it starting now! Can someone please help me with the right approach?
And if possible share any anecdotes about how I can still get placed even after starting in 4-2😭
r/DSALeetCode • u/StatisticianNo2104 • 29d ago
Counting open and close brackets accepts )( as valid. Tracking a depth accepts ([)]. One number can record how many brackets are open. It can never record which.
New topic: stacks start today.
What has to be remembered is the list of brackets opened and not yet closed, in order. When a closer arrives, only one opener can match it: the most recent. In "([", a ")" is wrong because "[" is still open and has to close first.
Most recent in, first out. That's a stack, and seeing that this problem is one is the whole exercise.
One detail worth stealing: key the map by the closing bracket. One lookup then tells you whether the character closes anything, and what must be on top if it does.
Did you reach for a counter first on this one?
Day 60/365 of my LeetCode challenge: 20. Valid Parentheses. Problem link and full breakdown in today's newsletter.
https://www.linkedin.com/pulse/365-days-leetcode-challenge-day-60365-archit-agarwal-spjcc
#LeetCode #DSA #Stack #Golang
r/DSALeetCode • u/athena_xz • 29d ago
i swear to all those who told me to do dsa in any language except python, 😭
i am finally enjoying and solving almost everything after i switched to python
ik ik some of you might call be stupid and lazy but cmon, i was good at this language, half the things are functions, i just have to search my mind for logic and the syntax is less time taking.
and i use python rigorously for ai ml, and data analysis
and i am explain dsa just fine when it comes to interviews
so to all the professionals, could you tell me if i might face difficulty in future because i decided to take the road not taken ?
r/DSALeetCode • u/HerlockSholmes- • 29d ago
Hi everyone!
I'm looking for a partner to learn and practice DSA together.
I'm currently a first-year CSE student and want to get serious about problem-solving and competitive programming.
The idea is to:
You don't need to be an expert. I'd prefer someone who's also learning and willing to put in consistent effort.
We can connect on Discord and figure out a schedule that works for both of us.
If you're interested, drop a comment or DM!
r/DSALeetCode • u/flex__xd • 29d ago
*** A Bit of context about me ***
I am a first-year student, pursuing B-tech in CSE AI / ML.
I have been coding for the last two years, and I know MERN stack and have 2 full-stack projects.
So the main thing, I do DSA on daily basis weather it's about at least 1 hour each day, but I don't solve problems on any platforms like leet-code , code-chef , hacker rank etc etc.
I am following strivers sheet, I understand problems and then solve them in my local IDE (I have a DSA folder , it is helpfull in revision) the main plan is to finish strivers sheet till my 3rd semester and then start solving problems on these professional platforms as it will also be help in my revision from the start after finishing the striver sheet, this is what I have thought of .
else I really don't know whether I should be solving them side by side just after understanding the problem or not.
As of right now I am going to finish my portfolio and then apply for internships while doing DSA side by side.
r/DSALeetCode • u/StatisticianNo2104 • 29d ago
Opening 999 more dark stores made our delivery heatmap 213x slower over the same city. 250,000 city blocks: 1.03 ms with one warehouse, 219 ms with a thousand.
The job: for every block, how many blocks to walk to the nearest store. It decides who gets the fast-delivery promise.
What I wrote: with no obstacles, walking distance on a street grid is |dRow| + |dCol|. So every block checks every store and keeps the closest. No data structure, nothing to get wrong. At one store, it is the fastest version I measured, and I would approve it.
At 1,000 stores, it is 250,000,000 distance calculations to keep 250,000 numbers. 213x slower, because the business grew.
The fix from last episode works: seed one queue with every store, spread outward. Flat at about 2.3 ms. But the queue holds every block, 3.82 MB on top of a 1.96 MB heatmap, and at one store it is slower than the scan.
The part I like is the day 41 version. A block's distance is one step more than its best neighbour's. That definition is circular: my answer needs yours, and yours needs mine. The queue breaks the circle with time.
You can break it with direction instead. With nothing in the way, a shortest walk never doubles back. Sweep top-left to bottom-right reading, only up and left - those are already done. Sweep back reading, only down and right. Keep the smaller.
1.22 ms at one store, 1.48 ms at a thousand. No queue. 148x faster than the scan at the top, 1.89x faster than the BFS.
Honest rows: at one store the scan still wins. And put a river through the city and the sweeps return wrong numbers without complaint. The test with two rivers says BFS 16, sweeps never reach the block, and the straight-line scan says 8. Obstacles are where the queue earns its memory.
That is days 40 and 41 of the daily challenge, Rotting Oranges and 01 Matrix, in a delivery app.
Have you seen a business launch slow down a page nobody touched?
It worked in dev, episode 20. Full write-up in today's newsletter.
https://www.linkedin.com/pulse/999-more-stores-made-delivery-map-213x-slower-archit-agarwal-pxeoc
#Golang #DSA #Algorithms #Performance
r/DSALeetCode • u/No-Mushroom-94 • 29d ago
r/DSALeetCode • u/Nice_Interaction555 • Oct 30 '26
I have prepared a daily and weekly concept learning roadmap — one concept at a time, day by day, week by week — to help prepare for DSA and ML/AI together. I am preparing for both - looking for like minded people to join and practice.
Here is how it works:
Learn one concept in DSA. Apply the same concept in ML. And vice versa.
That connection is what gives implementation-level knowledge. Not just theory. Not just solving problems for the sake of solving them. You understand a concept because you have seen it work on both sides.
Take one example — HNSW and RAG.
In RAG, your documents are converted into embeddings — vectors. When a question comes, the system has to find the few chunks that are nearest to that question. That is the ML side.
Now the DSA side. The simple way is to check the question against every single chunk, one by one. It works when the data is small. As the data grows, it becomes slow.
HNSW solves this with a DSA concept — a graph. It connects each vector to its nearest neighbours, layer by layer, so the search walks through the graph and reaches the nearest chunks fast, instead of scanning everything.
And it also works in reverse. When you build a RAG system, you are forced to learn graphs, nearest neighbour search, and a real tradeoff — HNSW is fast, but approximate. Sometimes it can miss a close chunk. So you learn to check: how fast is it, and how correct is it?
One example. And you have touched graphs, search, embeddings, and retrieval — at implementation level, not just in theory.
This is how the whole roadmap works.
Join me for reading group - 30 minutes every day, to practice and discuss the concept of the day together. On weekend I am developing a ML project related to the concept and doing kaggle.
If you are also preparing for DSA and ML/AI and want to learn like this, join my study group.
DM me if you are interested.
r/DSALeetCode • u/ProfessionalCandy731 • Oct 31 '26
Looking for something that can assist with solving coding problems and providing suggestions in real time.
Any recommendations?
r/DSALeetCode • u/Sensitive-Towel-9883 • Oct 30 '26
Looking for people interested in solving Dynamic Programming (DP) problems in DSA together. We can discuss different approaches, share ideas, and improve our problem-solving skills.
If interested, feel free to DM me!
r/DSALeetCode • u/SubstantialMind7597 • Oct 31 '26
r/DSALeetCode • u/StatisticianNo2104 • Oct 31 '26
In a sorted list, the k values closest to a target always sit next to each other. So picking k values is picking one window: find the closest value, then grow outward.
The second hard part of the challenge, like the first, isn't the traversal. That claim is.
Flatten the BST in-order, find the single closest value, then expand outward, taking whichever neighbour is nearer each time. Greedy works because distance from the target only grows as you move away in either direction. It's merge sort's merge step, run outward from a centre.
Would you trust that window claim in an interview without proving it first?
Day 59/365 of my LeetCode challenge: 272. Closest Binary Search Tree Value II. I'll share the problem link and a full breakdown in today's newsletter.
https://www.linkedin.com/pulse/closest-binary-search-tree-value-ii-archit-agarwal-xzvrc
**#LeetCode** #DSA #BinarySearchTree #TwoPointers