You are viewing a single comment's thread. Return to all comments →
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions , feel free to give a star :) )
void levelOrder(Node * _root) { using namespace std; auto nodes = queue<decltype(_root)>({_root}); decltype(_root) node = nullptr; while(!nodes.empty()){ node = nodes.front(); nodes.pop(); cout << node->data << " "; if(node->left){ nodes.emplace(node->left); } if(node->right){ nodes.emplace(node->right); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Level Order Traversal
You are viewing a single comment's thread. Return to all comments →
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions , feel free to give a star :) )