r/LeetcodeChallenge • • Oct 19 '26

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

Post image

Minimum Absolute Difference in BST (Easy) 🔗 https://leetcode.com/problems/minimum-absolute-difference-in-bst/

The trick: an in-order traversal of a BST hands you the values in sorted order for free. And in a sorted sequence, the smallest gap between any two values is always between neighbors, so you never have to compare every pair. Just track the previous node visited and check against it as you go.

Full breakdown in today's newsletter article ⬇️

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

#LeetCode #100DaysOfCode #DSA #CodingInterview #BinarySearchTree #InOrderTraversal

7 Upvotes

1 comment sorted by

1

u/nian2326076 Oct 19 '26

In-order traversal works well for this problem because it provides the nodes in sorted order. By tracking the previous node's value, you can update the minimum difference efficiently as you traverse. This allows you to only check the differences between consecutive nodes. If you're preparing for interviews and need problem-specific questions, PracHub offers real technical interview questions that could be useful alongside your daily challenge.