kotlin-coding-challenges

Tree level width

Nice to solve before

Tree traversal

Instructions

Given the root node of a tree, return a list where each element is the width of the tree at each level.

Challenge Solution

Examples

    A
  / |  \
B   C   D
|       |
E       F

Answer: [1, 3, 2]