102. Binary Tree Level Order Traversal

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: vector<vector<int>> levelOrder(TreeNode* root) { if (root == nullptr){ return; } queue <TreeNode*> q; q.push(root); while(!q.empty()){ int size = q.size(); for (int i = 0; i < q.size(); i++){ q.pop(); if (){ } } } } };
Unfinished.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.