LintCode 6---合并排序数组 II

import java.util.Arrays;

public class Lint6 {
/*
 *     合并两个排序的整数数组A和B变成一个新的数组。新数组也要有序。
 */
    public static void main(String[] args) {
    }
    public int[] mergeSortedArray(int[] A, int[] B) {
        int[] C = new int[A.length+B.length];
        for (int i = 0; i < A.length; i++) {
            C[i] = A[i];
        }
        for (int i = 0; i < B.length; i++) {
            C[i+A.length] = B[i];
        }
        Arrays.sort(C);
        return C;
    }
}

猜你喜欢

转载自www.cnblogs.com/cnmoti/p/10817095.html