Maximum Width of Binary Tree
Given the root of a binary tree, return the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels. The width of one level is defined as the length between the end-nodes (the leftmost and rightmost non-null nodes), where the null nodes between the end-nodes that would be present in a complete binary tree are also counted.
Maximum Width of Binary Tree

Given the root of a binary tree, return the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels. The width of one level is defined as the length between the end-nodes (the leftmost and rightmost non-null nodes), where the null nodes between the end-nodes that would be present in a complete binary tree are also counted.

Example 1:
Input: [1,3,2,5,3,null,9]
Output: 4
Input
arr =[1,3,2,5,3,null,9]

Start BFS traversal to find maximum width

Max Width: 1
At Level: 0
Current Level
Leftmost
Rightmost
Binary Tree (level-order)
Level 0:

1

Level 1:

3

2

Level 2:

5

3

9

Level 0: 1 node(s)

Positions: [0]

Width: rightmost - leftmost + 1 = 0 - 0 + 1 = 1

Maximum Width: 1 (at level 0)

Variables
No variables to display
DepthFunction Call
Stack empty
0/4