Skip to content

Latest commit

 

History

History
77 lines (37 loc) · 871 Bytes

README_EN.md

File metadata and controls

77 lines (37 loc) · 871 Bytes

中文文档

Description

Write an algorithm to find the "next" node (i.e., in-order successor) of a given node in a binary search tree.

Return null if there's no "next" node for the given node.

Example 1:

Input: root = [2,1,3], p = 1



  2

 / \

1   3



Output: 2

Example 2:

Input: root = [5,3,6,2,4,null,null,1], p = 6



      5

     / \

    3   6

   / \

  2   4

 /   

1



Output: null

Solutions

Python3

Java

...