方法一: reverse ArrayList
1 private void reverse(ArrayList<Integer> nums, int start, int end) { 2 for (int i = start, j = end; i < j; i++, j--) { 3 int temp = nums.get(i); 4 nums.set(i, nums.get(j)); 5 nums.set(j, temp); 6 } 7 }
时间: 2024-11-07 13:10:46