C++ | level order right->left + reverse


#1
vector<int> Solution::solve(TreeNode* A) {
    if(not A)   return {};
    queue<TreeNode *> q;
    vector<int> res;
    q.push(A);
    while(not q.empty()) {
        int len = q.size();
        for(int i=0; i<len; i++) {
            TreeNode *temp = q.front();
            q.pop();
            res.push_back(temp->val);
            if(temp->right) q.push(temp->right);
            if(temp->left) q.push(temp->left);
        }
    }
    reverse(res.begin(), res.end());
    return res;
}