Convert Sorted Linked List to BST

Problem

Time and Space Complexity

n -> Number of nodes in Linked List

circle-info

Time Complexity:

O(N log N)

Explanation:

  • The time complexity of building a BST is O(NlogN).

  • The time complexity of merging two BSTs is O(N).

  • Therefore, the overall time complexity of your algorithm is O(NlogN).

circle-check

Space Complexity

Solution

Last updated