leetcode地址,Java版代码:
1 class Solution { 2 public int[] printNumbers(int n) { 3 int end = (int)Math.pow(10, n) - 1; 4 int[] res = new int[end]; 5 for(int i = 0; i < end; i++) 6 res[i] = i + 1; 7 return res; 8 } 9 }
leetcode地址,Java版代码:
1 class Solution { 2 public int[] printNumbers(int n) { 3 int end = (int)Math.pow(10, n) - 1; 4 int[] res = new int[end]; 5 for(int i = 0; i < end; i++) 6 res[i] = i + 1; 7 return res; 8 } 9 }