class Solution {
public int[] getConcatenation(int[] nums) {
int[] result = new int[nums.length * 2];
System.arraycopy(nums, 0, result, 0, nums.length);
System.arraycopy(nums, 0, result, nums.length, nums.length);
return result;
}
}
class Solution {
public int[] getConcatenation(int[] nums) {
int[] result = new int[nums.length * 2];
for (int i = 0; i < nums.length; i++) {
result[i] = nums[i];
result[i + nums.length] = nums[i];
}
return result;
}
}
'Coding Test > 리트코드' 카테고리의 다른 글
[리트코드/자바] 1603. Design Parking System (0) | 2023.08.07 |
---|---|
[리트코드/자바] 1920. Build Array from Permutation (0) | 2023.08.07 |