一、题目
二、代码
class Solution
{
public void merge(int[] nums1, int m, int[] nums2, int n)
{
int length = m +n;
int[] my_nums = new int[length];
int index1 = 0;
int index2 = 0;
int index = 0;
int i ;
while(index<length)
{
if(index1<m&&index2<n)
{
if(nums1[index1]<=nums2[index2])
{
my_nums[index] = nums1[index1++];
}
else
{
my_nums[index] = nums2[index2++];
}
}
else if(index1==m&&index2<n)
{
my_nums[index] = nums2[index2++];
}
else if(index1<m&&index2==n)
{
my_nums[index] = nums1[index1++];
}
index++;
}
for(i=0;i<length;i++)
{
nums1[i] = my_nums[i];
}
}
}