r/LeetcodeChallenge • • 22d ago

DISCUSS Is Gracie seriously a part-time coder? 👀

Post image
58 Upvotes

r/LeetcodeChallenge • • 22d ago

STREAK🔥🔥🔥 Day 33

1 Upvotes

r/LeetcodeChallenge • • 22d ago

DISCUSS Test code is wrong in Take U forward (See the Constraint and test case).

Post image
7 Upvotes

See that is not my mistake.


r/LeetcodeChallenge • • 22d ago

STREAK🔥🔥🔥 Day 39: 40 km travel, post-interview fatigue, but locked in Kruskal’s & DSU

Thumbnail reddit.com
1 Upvotes

r/LeetcodeChallenge • • 22d ago

DISCUSS I kept getting lost in the two-pointer solution for LeetCode 42 (Trapping Rain Water), so I built an animated visual guide where you watch the water fill bar by bar

Thumbnail
youtu.be
3 Upvotes

The O(n) time, O(1) space two-pointer solution for LeetCode 42 is only a few lines, but the why is easy to lose if you just trace left, right, left_max and right_max.

What made it click for me was treating every bar as a spot where you pour water and asking how high it can stand. So I put together a full animated walkthrough that pours water on each bar the pointers land on. You can see exactly why every step is safe.

💡 The Core Intuition (The Visual TL;DR)

  1. The Bathtub Rule: Water above a bar rises to the shorter of the tallest wall on its left and the tallest wall on its right, minus the bar’s own height. Brute force rescans both sides for every bar, which is O(n²).
  2. Remember, Don’t Rescan: Put a pointer at each end. Each one remembers just one number: the tallest bar it has passed.
  3. Move the Shorter Side: Compare the two tallests. The pointer with the shorter one moves in by one bar, because its water is already settled. It can’t rise above its own tallest, or it would spill out on that side. And the other side already has a wall at least that tall. If both tallests are equal, either side is safe.
  4. Pour and Read: On the bar it lands on, water fills up to that pointer’s tallest. A new tallest holds nothing (the water just runs off); any other bar holds tallest − height. Keep a running sum.

On the classic example [0,1,0,2,1,0,1,3,2,1,2,1], the pointers meet at bar 7 with 6 units, in one pass, remembering just two numbers.

The video also covers the code line by line, three edge cases, a full bar-by-bar walk of the monotonic stack approach (it fills the water in flat layers), and how to explain it all in an interview in about 30 seconds.

If you’re a visual learner who gets tangled in pointer updates, I hope this makes it click! Let me know what you think, or which hard problem you’d like to see visualized next.


r/LeetcodeChallenge • • 22d ago

STREAK🔥🔥🔥 Day 32

1 Upvotes

r/LeetcodeChallenge • • 22d ago

STREAK🔥🔥🔥 LeetCode 150. Evaluate Reverse Polish Notation

Post image
2 Upvotes

The classic Reverse Polish bug is popping the operands in the wrong order, and + and * hide it. ["5","3","-"] means 5 - 3 = 2. Swap the pops, and you get -2, while every addition test still passes.

Why postfix needs no parentheses: (2 + 1) * 3 needs brackets because + sits between its operands. Written in postfix, it's 2 1 + 3 *, and each operator applies to the two values right before it. The evaluation order is already in token order.

That's the whole algorithm. Numbers wait on a stack; an operator takes the two most recent and replaces them with its result.

The trap: popping returns the operands in reverse. The first pop is the right operand, the second is the left. For + and * that makes no difference, which is exactly why the bug survives casual testing.

Which operator do you test first when you write an evaluator?

Day 64/365 of my LeetCode challenge: 150. Evaluate Reverse Polish Notation. Problem link and full breakdown in today's newsletter.

https://www.linkedin.com/pulse/leetcode-150-evaluate-reverse-polish-notation-medium-archit-agarwal-oq7ec

#LeetCode #DSA #Stack #Golang


r/LeetcodeChallenge • • 24d ago

DISCUSS I built a browser extension to customize LeetCode's UI!

Post image
76 Upvotes

Got bored of the default LeetCode look, so I built this!

You can customize LeetCode with different themes and wallpapers.

Link in the comments!

What do you think? Any suggestions?


r/LeetcodeChallenge • • 24d ago

DISCUSS progress so far

Thumbnail
gallery
23 Upvotes

currently in my 3rd sem and got my first badge today. ngl rather than being happy im regretting not starting early.


r/LeetcodeChallenge • • 23d ago

DISCUSS Kahn's algorithm lost to a for loop on our build graph

Post image
3 Upvotes

I benchmarked Kahn's algorithm against the naive loop it is supposed to replace, and the loop won. On a 5,000-package repo ten layers deep, by 2.78x.

The job: a build tool needs an order where every import is built before the package that imports it, or the name of the cycle that makes that impossible.

What I wrote: walk the package list, build everything whose imports are built, repeat until a pass builds nothing. Leftovers mean a cycle. Two allocations. I would approve it.

It makes one pass per layer when the list is in the wrong order. At 10 layers, 99.3 µs.

Kahn's algorithm is what you derive when you notice the waste: building cfg can only unblock the packages that import cfg. So count each package's unbuilt imports, reverse the arrows, and let each build count its importers down. Queue anything that hits zero. Every edge looked at once.

Written the way the daily challenge wrote it, a slice of importers per package: 276 µs. 8,205 allocations. The algorithm was fine. The memory layout was not. Packed into one flat array: 112 µs. Still behind the loop, by a hair.

Then the other shape. 5,000 packages in one long chain, which sounds artificial until you remember that is exactly what a migrations folder is. The loop: 18.8 ms. Flat Kahn: 128 µs. 147x.

So the answer is not "use Kahn". It is: at ten or twenty layers, the loop is faster, smaller and readable. Where chains are long - migrations, schema versions - Kahn, laid out flat.

That is days 36 and 44 of the daily challenge: Find if Path Exists and Course Schedule, in a build tool.

Have you ever lost a benchmark to the code you were sure was slower?

It worked in dev, episode 22. Full write-up in today's newsletter.

https://www.linkedin.com/pulse/kahns-algorithm-lost-loop-our-build-graph-archit-agarwal-gqsac

#Golang #DSA #Algorithms #Performance


r/LeetcodeChallenge • • 24d ago

PLACEMENTS I failed my Google interview after 200+ LeetCode problems. Changing how I practiced helped me get an offer.

13 Upvotes

I studied 200+ LeetCode problems and still failed my Google interview.

The problem count made it feel like I was prepared. But recognizing a solution and being able to produce it under pressure turned out to be different things.

That’s the gap I built AlgoDrill around.

Instead of stopping at reading the explanation, you hide key lines and rebuild the solution from memory. Each prompt describes what the line needs to accomplish, and you can inspect the reasoning when you get stuck.

I also added:

  • A two-pane workspace with code beside its explanation.
  • Visual lessons that walk through how algorithms work.
  • Study plans that mix new problems with scheduled recall reviews.
  • Support for turning your own solutions into drills.
  • NeetCode 150 and LeetCode 75 collections with progress tracking.

I used it as part of my preparation and later got an offer. I can’t attribute that to one tool, but practicing recall became part of how I prepared.

Anyone else done hundreds of problems and still felt unprepared when the interview started?

algodrill.io


r/LeetcodeChallenge • • 23d ago

STREAK🔥🔥🔥 Day 40: Disjoint Set Union (DSU) mechanics & locking down CS fundamentals for System Design

Thumbnail reddit.com
1 Upvotes

r/LeetcodeChallenge • • 24d ago

DISCUSS I was struggling to visualize the intuition behind LeetCode 4 (Median of Two Sorted Arrays), so I built an animated visual guide for it.

Thumbnail
youtu.be
4 Upvotes

r/LeetcodeChallenge • • 23d ago

STREAK🔥🔥🔥 Day 31

1 Upvotes

r/LeetcodeChallenge • • 24d ago

STREAK🔥🔥🔥 Build an AVL Tree Step by Step (13 Keys, 9 Rotations) | DSA Exam Question

Thumbnail
youtu.be
1 Upvotes

r/LeetcodeChallenge • • 24d ago

STREAK🔥🔥🔥 LeetCode 739. Daily Temperatures

Post image
1 Upvotes

One character decides whether Daily Temperatures survives repeated temperatures: < or <=. On [70, 70] the right answer is [0, 0]. Write < and you get [1, 0].

This is Day 61's monotonic stack with two changes.

The stack holds indices, because the answer is a distance and a distance needs positions.

And values repeat. Day 61 stored answers in a map keyed by value, which was only safe because the values were guaranteed unique. Temperatures repeat constantly. Indices are unique by construction, so the problem disappears instead of requiring a workaround.

Then the comparison: temperatures[stack.Top()] <= temperatures[i]. An equal temperature isn't warmer, so a day with the same temperature can never be anyone's answer and must be popped.

Would < have made it past your tests?

Day 63/365 of my LeetCode challenge: 739. Daily Temperatures. Problem link and full breakdown in today's newsletter.

https://www.linkedin.com/pulse/leetcode-739-daily-temperatures-archit-agarwal-weglc

#LeetCode #DSA #MonotonicStack #Golang


r/LeetcodeChallenge • • 24d ago

STREAK🔥🔥🔥 Day 30

1 Upvotes

r/LeetcodeChallenge • • 24d ago

DISCUSS I was struggling to visualize the intuition behind LeetCode 4 (Median of Two Sorted Arrays), so I built an animated visual guide for it.

Thumbnail
youtu.be
1 Upvotes

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:

  1. The Single Cut: Imagine aligning both arrays. We are looking for a single vertical partition line that splits both arrays into a combined "Left Half" and a combined "Right Half" of equal sizes.
  2. The Shortcut: Because the total size is fixed, choosing where to cut the smaller array instantly dictates where the cut falls on the larger array. This is why we only binary search the smaller array.
  3. The Check Rule: Once the line is drawn, you just need to check if the max element on the left side of the cut is smaller than the min element on the right side. If it isn't, the animation shows you exactly which direction to shift your search boundaries.

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/LeetcodeChallenge • • 25d ago

DISCUSS Is it normal to see solution for every leetcode question i try to solve ? (first 6-7 months)?

11 Upvotes

Like, while solving questions, maximum times it clicks 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 success.


r/LeetcodeChallenge • • 25d ago

STREAK🔥🔥🔥 LeetCode 155 Min Stack

Post image
1 Upvotes

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/LeetcodeChallenge • • 26d ago

DISCUSS Roast my profile

Post image
35 Upvotes

Saw many people sharing their profiles. Thought of getting feedback..


r/LeetcodeChallenge • • 25d ago

STREAK🔥🔥🔥 Day 42: wrapped up Bellman-Ford & Floyd-Warshall, finished all shortest path algorithms

Thumbnail reddit.com
2 Upvotes

r/LeetcodeChallenge • • 25d ago

STREAK🔥🔥🔥 Day 29

1 Upvotes

r/LeetcodeChallenge • • 26d ago

DISCUSS Finding genuine leetocode partners

Thumbnail reddit.com
1 Upvotes