285-Inorder-Successor-In-Bst
Sat 17 May 2025
https://leetcode.com/problems/inorder-successor-in-bst
import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
def inorderSuccessor(self, root: Optional[TreeNode], p: Optional[TreeNode]) -> Optional[TreeNode]:
if not root:
return None
if root.val <= p.val:
return self.inorderSuccessor(root.right, p)
return self.inorderSuccessor(root.left, p) or root
new Solution().inorderSuccessor()
Score: 5
Category: leetcode