you give root binary treeA ZigZag path binary tree define followchoose node binary tree direction right leftIf current direction right right child current node leave childChange direction right left leave rightrepeat second step can not treezigzag length define number node visit 1 a single node length 0return long ZigZag path contain tree Example 1input root 1null111nullnull11null1nullnullnull1null1output 3explanation Longest ZigZag path blue node right leave rightexample 2input root 111null1nullnull11null1output 4explanation Longest ZigZag path blue node leave right leave rightexample 3input root 1output 0 ConstraintsThe number nod tree range 1 5 1041 Nodeval 100