mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
530.二叉搜索树的最小绝对差 python迭代法没有取abs
This commit is contained in:
@ -233,7 +233,7 @@ class Solution:
|
||||
else: # 逐一处理节点
|
||||
cur = stack.pop()
|
||||
if pre: # 当前节点和前节点的值的差值
|
||||
result = min(result, cur.val - pre.val)
|
||||
result = min(result, abs(cur.val - pre.val))
|
||||
pre = cur
|
||||
cur = cur.right
|
||||
return result
|
||||
|
Reference in New Issue
Block a user