Maximum Width of Binary Tree

Medium
Trees Tree BFS DFS

Find maximum width of tree (distance between leftmost and rightmost nodes at any level).

Constraints

Nodes ≤ 3000

Examples

Example 1:
Input: 1 3 2 5 3 null 9
Output: 4
Example 2:
Input: 1 3 null 5 3
Output: 2
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.