那就暴力呗。根据n算出数组大小,然后赋值...



public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param n int整型 最大位数
     * @return int整型一维数组
     */
    public int[] printNumbers (int n) {
        // write code here
        int high = 1;
        while(n>0){
            high*=10;
            n--;
        }
        int res[] = new int[high-1];
        for(int i=1;i<high;++i){
           res[i-1] = i;
        }
        return res;
    }
}