leetcode算法题--打印从1到最大的n位数

原题链接:https://leetcode-cn.com/problems/da-yin-cong-1dao-zui-da-de-nwei-shu-lcof/

vector<int> printNumbers(int n) {
     
    int value = 1;
    for (int i = 0; i < n; i++) {
     
        value *= 10;
    }
    vector<int> ans;
    for (int i = 1; i < value; i++) {
     
        ans.push_back(i);
    }
    return ans;
}

你可能感兴趣的:(算法)