two method: inorder: use a global pointer the get pre val, compare with current pointer. But I think the code is hard to understand check each pointer’s value is in the range(min, max). update range.(recommend, it use tree common pattern)
two method:
- inorder: use a global pointer the get pre val, compare with current pointer. But I think the code is hard to understand
- check each pointer’s value is in the range(min, max). update range.(recommend, it use tree common pattern)
in inorder method:
1. first check left part is valid
2. assign current to prev, check its current part
3. last check its right part