We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
// Start of function levelOrderthis.levelOrder=function(root){if(!root)return;constqueue=[];queue.push(root);while(queue.length>0){constlevelSize=queue.length;for(leti=0;i<levelSize;i++){constnode=queue.shift();process.stdout.write(node.data+' ');if(node.left)queue.push(node.left);if(node.right)queue.push(node.right);}}};// End of function levelOrder
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 23: BST Level-Order Traversal
You are viewing a single comment's thread. Return to all comments →
in JS