标签:pre code ems ber https size 方法 while may
地址:https://leetcode.com/problems/merge-sorted-array/
描述:
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Note:
实例:
Input: nums1 = [1,2,3,0,0,0], m = 3 nums2 = [2,5,6], n = 3 Output: [1,2,2,3,5,6]
方法:
public int[] merge_4(int[] nums1, int m, int[] nums2, int n){ while(n>0){ nums1[m+n-1]=(m==0||nums2[n-1]>nums1[m-1])?nums2[--n]:nums1[--m];} return nums1; }
Leetcode-88. Merge Sorted Array
标签:pre code ems ber https size 方法 while may
原文地址:https://www.cnblogs.com/zimengfang/p/10798224.html