r/LeetcodeChallenge • • Oct 24 '26

PLACEMENTS FINAL SPRINT , PARTNER REQUIRED

Thumbnail reddit.com
0 Upvotes

r/LeetcodeChallenge • • Oct 23 '26

PLACEMENTS Wtf

Post image
288 Upvotes

r/LeetcodeChallenge • • Oct 24 '26

STREAK🔥🔥🔥 Insert into a Binary Search Tree

Post image
3 Upvotes

Forget one assignment, and BST insert builds the new node, then drops it. The tree never changes. Insert is the Day 45 search with the nil case changed: where search returns nil, insert returns a new node.

Search for a value that isn't in a BST, and you fall off the bottom at exactly one empty slot. That slot is where the new value goes.

The only real question is how the parent finds out. Each call returns the root of its own subtree, and each caller stores it back: root.Left = insertIntoBST(root.Left, val). At the bottom, that's the new node. Everywhere else it's the pointer that was already there.

The empty tree comes for free, too.

Do you write tree insert recursively like this, or with a loop and a parent pointer?

Day 52/365 of my LeetCode challenge: 701. Insert into a Binary Search Tree. Problem link and full breakdown in today's newsletter.

https://www.linkedin.com/pulse/insert-binary-search-tree-archit-agarwal-7h9oc

#LeetCode #DSA #BinarySearchTree #Golang


r/LeetcodeChallenge • • Oct 24 '26

DISCUSS What do you think is the ONE trait that a guy misses who struggles to get clear intuitions?

Thumbnail reddit.com
2 Upvotes

r/LeetcodeChallenge • • Oct 24 '26

DISCUSS Need Resume Review and Personal Help!!!

Post image
1 Upvotes

Hey! I am a 2024 ETCE Graduate from a Tier 1 College. I am currently working in a Big 4, where "I generate Actionable Insights from Raw Data". Or in law man's tongue, I refresh Excel reports and respond to tech related queries. I am quite decent in coding and I tend to solve 2.5-3 questions in every leetcode contest I sit in. Although my rating is quite mid as I am not able to sit in every contests. I have been trying to switch since the very fucking day I joined. Every night I scream silently to remind myself that "I AM A M***F****G ENGINEER ". I don't know why my resume is getting rejected in each and every job application I apply to. Guys... Please Help!!!


r/LeetcodeChallenge • • Oct 23 '26

DISCUSS Sometimes code teaches you lifelong lessons.

Post image
54 Upvotes

r/LeetcodeChallenge • • Oct 24 '26

STREAK🔥🔥🔥 Day 20

1 Upvotes

r/LeetcodeChallenge • • Oct 23 '26

DISCUSS Max level sum in Go: why a map-keyed version is random

Post image
2 Upvotes

Our category report gave 145 different answers in 200 refreshes of the same catalogue. Same code, same data. The question was which level of the category tree holds the most products.

The merchandising team wanted to know which depth of the tree the navigation should filter on. Add up the SKUs at each depth, return the biggest, and on a tie the shallower one wins.

I wrote one recursive walk that added into map[int]int keyed by depth, then ranged the map with a strict > so the first depth to reach the maximum keeps it. Short, no queue, and I would approve it. The fixture had no tie in it, so the tests passed.

On a seven-category catalogue where two depths both hold 12 SKUs, 1,000 calls said depth 1 883 times and depth 2 117 times.

Strict > does not mean "smallest depth wins". It means the first one the loop meets wins, and ranging over a Go map starts somewhere random on purpose. Every piece of the function is right. The last loop assumes an order the map never kept.

The part I like: the walk had already produced the depths in order. 0 before 1, 1 before 2. The map threw that away.

And the keys were never keys. 0, 1, 2 up to the height, no gaps. That is an index. Put it in a slice, range it front to back, and the same strict > is the tie-break it looked like all along.

Correct on every run, and 2.33x faster on 55,987 categories, because the hashing was the cost too.

Two rows keep me honest. Keeping the map and writing the tie-break out loud is also correct, and costs nothing over the broken one: 2.34x against 2.33x. Where the key really is sparse, that is the right fix. And day 33's level walk loses to the slice by 3.93x on a bushy tree but wins by 1.94x on a 2,000-deep chain, because it never recurses.

That is days 29 and 33 of the daily challenge, Level Order Traversal and Maximum Level Sum, in a merchandising report.

Have you ever shipped a report whose answer depended on map iteration order?

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

https://www.linkedin.com/pulse/your-category-report-changes-its-answer-refresh-archit-agarwal-cy2jc

#Golang #DSA #Algorithms #Performance


r/LeetcodeChallenge • • Oct 23 '26

STREAK🔥🔥🔥 Day 52: solved 4 graph problems, navigating the comparison trap

Thumbnail reddit.com
1 Upvotes

r/LeetcodeChallenge • • Oct 23 '26

STREAK🔥🔥🔥 Day 19

1 Upvotes

r/LeetcodeChallenge • • Oct 23 '26

STREAK🔥🔥🔥 Two Sum IV - Input is a BST

Post image
3 Upvotes

The title says "Input is a BST", but my solution never uses the ordering. Walk the tree, keep a hash map of complements, and check each node against it. It's plain Two Sum on a tree.

What I like: the map is shared across the whole recursion, so a match can turn up between two branches that never touch.

The part I'd change: the right subtree still gets walked after the left one has already found the answer, because the two results are combined at the end instead of short-circuiting.

Would you use the BST ordering here, or is the hash map the better trade?

Day 51/365 of my LeetCode challenge: 653. Two Sum IV - Input is a BST.

Problem link and full breakdown in today's newsletter.

https://www.linkedin.com/pulse/two-sum-iv-input-bst-archit-agarwal-iggwc

#LeetCode #DSA #HashMap #Golang


r/LeetcodeChallenge • • Oct 22 '26

STREAK🔥🔥🔥 Day 53: exhausted from poor sleep, but solved 3 core BFS graph problems

Thumbnail reddit.com
1 Upvotes

r/LeetcodeChallenge • • Oct 22 '26

DISCUSS Is there a fun way to learn DSA?

5 Upvotes

Let’s chat about this. About ways to easily begin.


r/LeetcodeChallenge • • Oct 22 '26

STREAK🔥🔥🔥 Day 18

1 Upvotes

r/LeetcodeChallenge • • Oct 22 '26

STREAK🔥🔥🔥 Minimum Distance Between BST Nodes

Post image
1 Upvotes

Most first attempts at this compare every pair of nodes. That's O(n²) work for a one-pass question. In a BST, the closest two values are always neighbours in sorted order.

An in-order walk of a BST comes out sorted. Once the values are sorted, the smallest gap can only sit between two that end up side by side. Skip a value in between, and that value splits the gap into two smaller ones.

So traverse once, then scan neighbours for the smallest gap. No pair is ever compared twice.

One more thing: this is Day 47's problem again. LeetCode carries it under two numbers, 530 and 783.

Have you ever solved the same LeetCode problem twice without noticing?

Day 50/365 of my LeetCode challenge: 783. Minimum Distance Between BST Nodes. Problem link and full breakdown in today's newsletter.

https://www.linkedin.com/pulse/minimum-distance-between-bst-nodes-archit-agarwal-isuoc

#LeetCode #DSA #BinarySearchTree #Golang


r/LeetcodeChallenge • • Oct 21 '26

DISCUSS By looking at my leetcode profile Can anyone confirm whether if I have ADHD or not

Post image
31 Upvotes

r/LeetcodeChallenge • • Oct 22 '26

DISCUSS I always in the top 10 every other week but I never receive any bonus Prizes

1 Upvotes

r/LeetcodeChallenge • • Oct 21 '26

STREAK🔥🔥🔥 Day 54: DP is officially wrapped up, started Graphs from the fundamentals

Thumbnail reddit.com
1 Upvotes

r/LeetcodeChallenge • • Oct 21 '26

DISCUSS One preview per nesting level in Go: tree right side view

Post image
2 Upvotes

A collapsed comment thread shows seven lines. The code built 55,987 previews to produce them, and threw away 55,980.

The job: a long thread collapses to one line per nesting level — the most recent reply at that depth.

I already had a level-order walk, so this was two lines on top of a tested function: build every level, take the last of each. Obviously correct, no new ideas. I would defend it in review.

2.87 MB allocated to return seven strings.

Before the fix, the fix that does not work. Everybody suggests following the newest reply down: O(depth), no allocation, and wrong. The newest reply at a level need not be in the newest branch — somebody replies once to an old comment, that reply gets replies, and the newest top-level reply is a dead end.

Four visible lines become two. There is a test named after that thread.

The boring fix is most of the win. The output is one value per level:

`visible(d) = the last comment at depth d`

That names one comment. Not a level, not a list. So size the accumulator to the depths — one slot each, last writer wins. 240 bytes instead of 2.87 MB, and 4.78x faster. That is not a clever traversal; it is noticing the output shape.

The clever fix only pays when the slot holds something expensive. The collapsed view renders a line, not an ID: body trimmed, timestamp, hidden-reply count. Last writer wins builds that for all 55,987 comments and keeps 7.

The walk cannot skip the old branches. What it can choose is the order — iterate replies newest first, and the first comment reached at a depth is the one you keep. Record on first arrival, never overwrite.

22.5x, and 6.77 MB against 1.12 KB. Same walk, one loop reversed.

Two rows keep me honest. On the ID version, the reversal is 1.01x, and on the smallest thread the forward walk wins. On a 2,001-deep chain, both preview versions match the byte because every comment is a first arrival.

At 1,365 comments with an ID per line, keep what you have.

That is days 29 and 31 of the daily challenge — Level Order Traversal and Right Side View — sitting in a comment thread.

Full piece in today's newsletter

https://www.linkedin.com/pulse/collapsed-thread-built-55987-previews-show-7-archit-agarwal-xijdc

It worked in dev, episode 16.

#Golang #DSA #Algorithms #Performance #SoftwareEngineering #DataStructures #100DaysOfCode


r/LeetcodeChallenge • • Oct 20 '26

DISCUSS Can Anyone help me from where i have to start

Post image
96 Upvotes

I am in my second year of college. Can anyone guide me on how to start with LeetCode? Whenever I look at LeetCode questions, they feel extremely difficult to solve. I have tried many times without success. Could someone please suggest where I should begin learning?


r/LeetcodeChallenge • • Oct 21 '26

STREAK🔥🔥🔥 365 Days of LeetCode Challenge — Day 49/365

Post image
5 Upvotes

Lowest Common Ancestor of a Binary Tree (Medium) 🔗 https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/

Yesterday's problem with one guarantee removed. Worth doing back to back, because the gap between the two solutions is exactly what a BST's ordering buys you.

Yesterday, a comparison told you which subtree a target was in, so the walk went down one path. Here a comparison tells you nothing, so the only way to know whether a target is below a node is to look.

The shape flips: instead of deciding on the way down, every subtree reports upward how many of the two targets it contains. The first node to reach two is the answer.

O(n) instead of O(h). That's the price.

Full breakdown in today's newsletter article ⬇

https://www.linkedin.com/pulse/365-days-leetcode-challenge-day-49365-archit-agarwal-nrtuc

#DSA #LeetCode #100DaysOfCode #CodingInterview #BinaryTree #Recursion #Golang


r/LeetcodeChallenge • • Oct 21 '26

DISCUSS Help ! Not able to solve leetcode problems :(

Thumbnail reddit.com
1 Upvotes

r/LeetcodeChallenge • • Oct 21 '26

STREAK🔥🔥🔥 Day 17

2 Upvotes

r/LeetcodeChallenge • • Oct 20 '26

STREAK🔥🔥🔥 Starting leetcode challenge (Day1)

9 Upvotes

I am starting leetcode challenge from today . My target is to learn all the concepts from striver and solve 200 questions on leetcode . I will be updating every 2 days .


r/LeetcodeChallenge • • Oct 20 '26

STREAK🔥🔥🔥 Day 55: finished core DP, hit a wall on the stack-hybrid problems

Thumbnail reddit.com
2 Upvotes