Leetcode 1038 - Binary Search Tree to Greater Sum Tree [25/6/24]

Поділитися
Вставка
  • Опубліковано 23 чер 2024
  • Time Taken: ~25 mins
    Tag: LeetCode Medium
    Basic ideas:
    - Base case: if root is NULL, return NULL
    - Traverse right subtree. Wishful thinking that this would make currSum the sum of the right subtree added to existing currSum value.
    - Add currSum to current node’s value and update currSum to “current node’s value after addition”.
    - Traverse left subtree.

КОМЕНТАРІ •