碼牛移動高級開發(fā)VIP正式課二三四期
private void mergeTwoSortedArray(int[] nums, int[] temp, int start, int mid, int end) {
? ? ? ?// merge two sorted array
? ? ? ?int index = start;
? ? ? ?int first = start;
? ? ? ?int second = mid + 1;
? ? ? ?while (first <= mid && second <= end) {
? ? ? ? ? ?if (nums[first] < nums[second]) {
? ? ? ? ? ? ? ?temp[index++] = nums[first++];
? ? ? ? ? ?} else {
? ? ? ? ? ? ? ?temp[index++] = nums[second++];
? ? ? ? ? ?}
? ? ? ?}
標(biāo)簽: