0
点赞
收藏
分享

微信扫一扫

【YOLOv9】训练模型权重 YOLOv9.pt 重新参数化轻量转为 YOLOv9-converted.pt

新鲜小饼干 03-13 08:30 阅读 3

文章目录

题目描述

思路

复杂度

时间复杂度:

空间复杂度:

Code

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    /**
     * BFS
     * @param root The root of the binary tree 
     * @return vector<vector<int>>
     */
    vector<vector<int>> levelOrder(TreeNode *root) {
        if (root == nullptr) {
            return vector<vector<int>>();
        }
        vector<vector<int>> res;
        queue<TreeNode *> tmp;
        tmp.push(root);
        while (!tmp.empty()) {
            vector<int> level;
            int curLeveSize = tmp.size();
            for (int i = 0; i < curLeveSize; i++) {
                TreeNode *node = tmp.front();
                tmp.pop();
                level.push_back(node->val);
                if (node->left != nullptr) {
                    tmp.push(node->left);
                }
                if (node->right != nullptr) {
                    tmp.push(node->right);
                }
            }
            res.push_back(level);
        }
        return res;
    }
};
举报

相关推荐

0 条评论