Skip to content

Commit fb07581

Browse files
authored
Create 1920. Build Array from Permutation
1 parent e5fdde4 commit fb07581

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

1920. Build Array from Permutation

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public int[] buildArray(int[] nums) {
3+
int CONST = 1001;
4+
5+
for(int i = 0; i < nums.length; i++) {
6+
int a = nums[i];
7+
int b = nums[a]%CONST;
8+
nums[i] = a + b*CONST;
9+
}
10+
11+
for(int i = 0; i < nums.length; i++) {
12+
nums[i] /= CONST;
13+
}
14+
15+
return nums;
16+
17+
}
18+
}

0 commit comments

Comments
 (0)