You are given an integer array order representing the insertion order of elements into an initially empty Binary Search Tree (BST).
Return the maximum depth of the resulting BST after inserting all elements in order without performing any rebalancing operations.
The depth of a binary tree is defined as the number of nodes along the longest path from the root node down to the farthest leaf node.
Constraints:
n order.length
n
order is a permutation of integers from n.
You are given an integer array order representing the insertion order of elements into an initially empty Binary Search Tree (BST).
Return the maximum depth of the resulting BST after inserting all elements in order without performing any rebalancing operations.
The depth of a binary tree is defined as the number of nodes along the longest path from the root node down to the farthest leaf node.
Constraints:
n order.length
n
order is a permutation of integers from n.