Not able to pass all the test cases

How are you doing the zig zag?
Like how are you changing the direction of the traversal?