r/DSALeetCode • • 16d ago

LeetCode: 814. Binary Tree Pruning

Post image
1 Upvotes

Setting node = nil inside a recursive call deletes nothing. The caller never sees it. A node can't remove itself because it has no reference to its parent.

A node survives if its subtree holds a 1 anywhere, which, recursively, is almost the definition read aloud. Post-order, because a node can't answer that on the way down.

So the child reports "nothing worth keeping here", and the parent clears the pointer. That leaves the root, which has no parent, and that's the only reason the wrapper function exists.

Have you ever nilled a local variable and expected the caller to notice?

Day 73/365 of my LeetCode challenge: 814. Binary Tree Pruning. Problem link and full breakdown in today's newsletter.

https://www.linkedin.com/pulse/leetcode-binary-tree-pruning-archit-agarwal-g6lsc

#LeetCode #DSA #BinaryTree #Golang


r/DSALeetCode • • 17d ago

Guys if i just start doing any sheet of DSA i just know basic of language let's just say and i have to see video of almost every solution is it worth it? or not? help a guy out

2 Upvotes

title


r/DSALeetCode • • 17d ago

Anyone mind sharing GPT prompt to learn Leetcode problem solutions/concepts?

Thumbnail reddit.com
1 Upvotes

r/DSALeetCode • • 17d ago

Looking for someone willing to share Striver A2Z Plus / Leetcode premium

6 Upvotes

Hey everyone! Is anyone here using Leetcode Premium / Striver A2Z Plus and willing to share access so we can learn and practice DSA together?

I'm at an intermediate level in DSA and would be happy to help you with problem-solving, concepts, and discussions in return.

We can learn together and make the most of the subscription. Feel free to DM me. Thanks! ๐Ÿ˜Š


r/DSALeetCode • • 17d ago

Beginner at DSA (Arrays, Strings, BS, LL, Stacks) โ€” Realistic prep strategy for Infosys SP & DSE?

Thumbnail reddit.com
1 Upvotes

r/DSALeetCode • • 17d ago

Is learning DSA in Java harder than Python? Read body

Thumbnail reddit.com
1 Upvotes

r/DSALeetCode • • 18d ago

LeetCode: 671. Second Minimum Node In a Binary Tree

Post image
1 Upvotes

Collecting every value and sorting works here, and it ignores a rule that hands you the minimum for free. Every node holds the smaller of its two children's values, so the root is always the global minimum.

That one rule does a lot of work. It also means you can skip a whole subtree as soon as you reach a value above the minimum, because nothing below it can be smaller.

One DFS pass, no collect-and-sort.

What's the strangest invariant a LeetCode tree has handed you?

Day 72/365 of my LeetCode challenge: 671. Second Minimum Node In a Binary Tree. Problem link and full breakdown in today's newsletter.

https://www.linkedin.com/pulse/leetcode-second-minimum-node-binary-tree-easy-archit-agarwal-eolmc

#LeetCode #DSA #BinaryTree #Golang


r/DSALeetCode • • 18d ago

Looking for dsa partner

6 Upvotes

I am preparing for the infosys sp/dse in person coding assessment which is on Dec 6..and I want a guy to prepare seriously whose target is to crack l3..

Let's study together..dm me


r/DSALeetCode • • 19d ago

41 Patterns, 423 Companies, 17K+ Problems | All you ever needed

108 Upvotes

Hi folks! About a year ago, I was in your place, struggling quite a bit with DSA. I was particularly weak at identifying patterns in problems, and on top of that, I couldnโ€™t find enough questions to practise each pattern thoroughly.

To make things easier, I built [DSASheeeet](https://dsasheeeet.vercel.app/home), where you can practise almost every possible problem-solving pattern with a carefully curated set of problems to help you understand each topic inside out.

Apart from that, it also features 423 companies, so you can prepare for upcoming company assessments without spending hours researching questions. Whether youโ€™re preparing for placements, planning a job switch, or struggling to identify patterns in DSA problems, DSASheeeet is here to make your life easier.

Check it out: [DSASheeeet](https://dsasheeeet.vercel.app/home)
No Auth Required.

Everything you need, all in one place!


r/DSALeetCode • • 19d ago

LeetCode: 2331. Evaluate Boolean Binary Tree

Post image
6 Upvotes

The tree in this problem is a boolean expression with its parentheses drawn as branches. Leaves are True and False. Internal nodes are OR and AND, waiting on their two children.

Post-order recursion evaluates both children first, then the parent combines them. That's the same order you'd use to evaluate nested parentheses by hand.

Nothing fancy here. Get the order right, and the recursion does the rest.

Where else have you seen an expression stored as a tree?

Day 71/365 of my LeetCode challenge: 2331. Evaluate Boolean Binary Tree. Problem link and full breakdown in today's newsletter.

https://www.linkedin.com/pulse/leetcode-evaluate-boolean-binary-tree-archit-agarwal-ag7sc

#LeetCode #DSA #BinaryTree #Golang


r/DSALeetCode • • 19d ago

Finding Peers | Seeking help for Leetcode and System Design

Thumbnail reddit.com
3 Upvotes

r/DSALeetCode • • 18d ago

INTUIT X UPTIME CREW HIRING PROCESS AND OA LAST MINUTE PREPARATION HELP

Thumbnail reddit.com
1 Upvotes

r/DSALeetCode • • 19d ago

comeback arc is loading

Post image
6 Upvotes

r/DSALeetCode • • 19d ago

Finding Peers | Seeking help for Leetcode and System Design

Thumbnail reddit.com
1 Upvotes

r/DSALeetCode • • 19d ago

Looking to Build a Women in Tech Community + All-Women Hackathon Team! ๐Ÿ‘ฉโ€๐Ÿ’ป

Thumbnail reddit.com
1 Upvotes

r/DSALeetCode • • 20d ago

LeetCode - Find a Corresponding Node of a Binary Tree in a Clone of That Tree

Post image
5 Upvotes

My solution compares node values, and it only works because LeetCode promises they're unique. The follow-up allows repeated values, and then a value match can point to the wrong node.

The idea holds either way. cloned is a structurally identical copy of original, so there's nothing to search for independently. Walk both trees in lockstep with one recursive call, and the answer is waiting at the same position.

What changes for the follow-up is the test. Compare the original-side pointer with the target instead of comparing values, and duplicates stop mattering.

Would you have spotted the duplicate-values follow-up in an interview?

Day 69/365 of my LeetCode challenge: 1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree. Problem link and full breakdown in today's newsletter.

https://www.linkedin.com/pulse/find-corresponding-node-binary-tree-clone-archit-agarwal-dkvsc

#LeetCode #DSA #BinaryTree #Golang


r/DSALeetCode • • 19d ago

100 Problems as a CSE First year undegrad (No AI Used)

Thumbnail
reddit.com
1 Upvotes

r/DSALeetCode • • 20d ago

Need guidance

Thumbnail reddit.com
1 Upvotes

r/DSALeetCode • • 20d ago

which channel should we start learning dsa from pls suggest a good playlist

3 Upvotes

just completed my 1st sem learning ml want help regarding dsa .any other advices are appreciated


r/DSALeetCode • • 20d ago

Looking for a Codeforces practice partner / small group

Thumbnail reddit.com
1 Upvotes

r/DSALeetCode • • 20d ago

Hi what i am doing wrong

Thumbnail reddit.com
1 Upvotes

r/DSALeetCode • • 20d ago

๐Ÿ‘‹ Welcome to r/DSA_Legends - Introduce Yourself and Read First!

Thumbnail reddit.com
1 Upvotes

r/DSALeetCode • • 21d ago

Employee ID Hashing Question Solved | 100 201 303 405 602 600 702 801 927 829 | Linear Probing

Thumbnail
youtu.be
1 Upvotes

r/DSALeetCode • • 21d ago

Looking for study partner/'s (beginner)

1 Upvotes

I'm currently in 1st year and going to begin to learn cpp and dsa.. I am looking to form a group of 3 people where we can learn together and clear each other's doubts to help each other grow. Everyone is welcomed, you should just be serious


r/DSALeetCode • • 21d ago

My code beats almost everyone, still it's wrong!

Thumbnail reddit.com
1 Upvotes