makeMiddle([1, 2, 3, 4]) → [2, 3]
makeMiddle([7, 1, 2, 3, 4, 9]) → [2, 3]
makeMiddle([1, 2]) → [1, 2]
Answer 1:
public int[] makeMiddle(int[] nums) {
return new int[]{nums[nums.length/2-1],nums[nums.length/2]};
}
public int[] makeMiddle(int[] nums) {
return new int[]{nums[nums.length/2-1],nums[nums.length/2]};
}
No comments :
Post a Comment