Trees Flashcards

1
Q

Vertical Order

A
  1. two queue “q” to process the element to get the “col “for the element
  2. Maintain map of column and lists use the col to get lsit and add value;
  3. If left, add it q and add it col q with col - 1, min(min, col - 1)
  4. for its col + 1 and max(max, col - 1)
  5. Finally iterate from the min to max and get the list from the hashmap and add it to the result
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Sum of root to leaf node

A
  1. recursive(root, sum)
  2. sum += sum * 10 + root.val
  3. recursive(left, sum) + recursive(right, sum)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly