05 August 2008
这道题就是按照ans[i] = nums[nums[i]]这个格式转换数组
1
2
3
4
5
6
7
8
9
10
11
12
13
class Solution {
public int[] buildArray(int[] nums) {
if (nums == null || nums.length == 0) {
return new int[0];
}
int len = nums.length;
int[] result = new int[len];
for (int i = 0; i < len; i++) {
result[i] = nums[nums[i]];
}
return result;
}
}