合并两个有序数组
2022-02-28 本文已影响0人
叫我颜先生
/*
- @Author: sumBorn
- @Date: 2022-02-23 22:13:28
- @LastEditTime: 2022-02-23 22:37:14
- @Description: https://leetcode-cn.com/leetbook/read/all-about-array/x9lhe7/
*/
/**
- @description: 2数组填满1数组的0,之后1数组排序
- @param {*}
- @return {*}
*/
public class Solution
{
public void Merge(int[] nums1, int m, int[] nums2, int n)
{
for (var i = m; i < m + n; i++)
{
nums1[i] = nums2[i - m];
}
for (var i = 0; i < m + n; i++)
{
for (var j = i + 1; j < m + n; j++)
{
if (nums1[i] > nums1[j])
{
int tmp = nums1[i];
nums1[i] = nums1[j];
nums1[j] = tmp;
}
}
}
}
}