Leetcodle(site is WIP!)

A new programming problem every day

Inorder Successor in BST

Given the root of a Binary Search Tree (BST) and an integer target, find the value of the in-order successor of the node that has the value target. The in-order successor of a node p is the node with the smallest key greater than p.key. If the target node has no in-order successor (i.e., it is the largest element in the tree), return -1. You can assume that all values in the BST are unique and the target value is guaranteed to exist in the tree.

Example:

Input:`root` = `[5, 3, 6, 2, 4, null, null, 1]`, `target` = `4`
Output:5
Test Cases
Attempts
Output
Output will appear here after you submit your code :)