package LeetCode.contact;
class Solution {
public int[] buildArray(int[] nums) {
int[] ans = new int[nums.length];
for (int i = 0; i < nums.length; i++) {
ans[i] = nums[nums[i]];
}
return ans;
}
}
public class leetcode_1920{
public static void main(String[] args){
Solution test = new Solution();
int [] nums = new int[] {0,2,1,5,3,4};
int[] a = test.buildArray(nums);
for (int i = 0;i<a.length;i++){
System.out.println(a[i]);
}
}
}
LeetCode_1920:基于排列构建数组:java
最新推荐文章于 2024-11-04 12:20:00 发布