题解 | #合并两个有序的数组#
合并两个有序的数组
https://www.nowcoder.com/practice/89865d4375634fc484f3a24b7fe65665
import java.util.*; public class Solution { public void merge(int A[], int m, int B[], int n) { if(n == 0) return; int i = m-1; int j = n-1; while(i>=0 && j>=0) {//目标:找到更大的元素 if(A[i] >= B[j]) { A[i+j+1] = A[i]; i--; } else { A[i+j+1] = B[j]; j--; } } if(i < 0) { while(j >= 0) { A[j] = B[j]; j--; } } } }