Skip to content

Commit 860defb

Browse files
author
oleg.vlasov
committed
Problem1920
1 parent d63224c commit 860defb

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

src/arrays/Problem1920.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package src.arrays;
2+
3+
public class Problem1920 {
4+
//https://leetcode.com/problems/build-array-from-permutation/
5+
6+
7+
public static void main(String[] args) {
8+
final int[] nums = {5, 0, 1, 2, 3, 4};
9+
final int[] ans = buildArray(nums);
10+
11+
}
12+
13+
public static int[] buildArray(final int[] nums) {
14+
// final int ans[] = new int[nums.length];
15+
final int value = -1;
16+
if (1 <= nums.length && nums.length <= 1000) {
17+
for (int i = 0; i < nums.length; i++) {
18+
if (0 <= nums[i] && nums[i] < nums.length) {
19+
20+
21+
}
22+
}
23+
}
24+
return nums;
25+
}
26+
27+
public static int[] buildArray2(int[] nums) {
28+
int l = nums.length;
29+
for (int i = 0; i < l; i++) {
30+
nums[i] = nums[i] + l * (nums[nums[i]] % l);
31+
}
32+
for (int i = 0; i < l; i++) {
33+
nums[i] = nums[i] / l;
34+
}
35+
return nums;
36+
}
37+
}
38+
39+
40+
41+
42+
43+

0 commit comments

Comments
 (0)