출처 : https://leetcode.com/problems/merge-sorted-array/
Merge Sorted Array - LeetCode
Can you solve this real interview question? Merge Sorted Array - You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 an
leetcode.com
class Solution {
public void merge(int[] nums1, int m, int[] nums2, int n) {
int A = m - 1;
int B = n - 1;
int C = m + n - 1;
while (A >= 0 && B >= 0)
nums1[C--] = (nums1[A] > nums2[B]) ? nums1[A--] : nums2[B--];
while(B>=0)
nums1[C--] = nums2[B--];
}
}