Tap here to switch tabs
Problem
Submissions

Problem: Depth of BST Given Insertion Order

Try to solve the Depth of BST Given Insertion Order problem.

Statement

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

  • 1≤1 \leq n ≤105\leq 10^5

  • order is a permutation of integers from 11 to n.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Depth of BST Given Insertion Order

Try to solve the Depth of BST Given Insertion Order problem.

Statement

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

  • 1≤1 \leq n ≤105\leq 10^5

  • order is a permutation of integers from 11 to n.