当前位置 : 主页 > 手机开发 > harmonyos >

leetcode-98-Validate Binary Search Tree

来源:互联网 收集:自由互联 发布时间:2023-08-26
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:

  1. inorder: use a global pointer the get pre val, compare with current pointer. But I think the code is hard to understand
  2. 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


上一篇:leetcode-680-Valid Palindrome II
下一篇:没有了
网友评论