r/LeetcodeChallenge • u/StatisticianNo2104 • 3d ago
STREAK🔥🔥🔥 LeetCode: 671. Second Minimum Node In a Binary Tree
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
1
u/nian2326076 3d ago
You're right about the efficiency of skipping subtrees in binary trees. For sharpening your skills, try practicing with structured problems. You can use PracHub to find diverse technical interview questions. This will help you get comfortable with various problem types and improve your problem-solving speed.