Javascript BFS
Its a standard BFS with but the difference is we are keeping track of the depth at each level and that\'s determines  if were adding to the front of the level a
Its a standard BFS with but the difference is we are keeping track of the depth at each level and that\'s determines  if were adding to the front of the level array or the back of the level array. \n\n```\nvar zigzagLevelOrder = function(root) {\n  if(!root) return [];\n  let queue = [root];\n  let output = [];\n  let deep = 0;\n  while(queue.length > 0){\n    const size = queue.length;\n    const level = [];\n    \n    for(let i=0; i< size; i++){\n      const node = queue.shift();\n      if(deep % 2 == 0) level.push(node.val);\n      else level.unshift(node.val);\n      \n      if(node.left) queue.push(node.left)\n      if(node.right) queue.push(node.right)\n    }\n    output.push(level)\n    deep++;\n  }\n  \n  \n  return output\n  \n  \n};\n```
['Breadth-First Search', 'JavaScript']