medium
binary-tree
binary-search-tree
depth-first-search
Return true if every node in root satisfies the strict binary-search-tree ordering rule.
Constraints
- 1 <= number of nodes <= 10000
- -2^31 <= node value <= 2^31 - 1
Follow-up
Why is checking only each node's immediate children insufficient?
Execution note
Java/Go/Rust don't support this problem's ListNode/TreeNode structure yet — the starter is reference-only. Try Python or JavaScript to run and submit.
Examples
Example 1
Input: root = [2,1,3]
Output: true
Example 2
Input: root = [5,1,4,null,null,3,6]
Output: false
Example 3
Input: root = [1]
Output: true
🔒 5 hidden
Running will execute all 8 cases, including 5 hidden ones.