My 5lines&&4ms c++ solution


  • -10
    J
    class Solution {
    public:
        void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
            for(int i=m;i<n+m;i++) 
            {
                nums1[i]=nums2[i-m];
            }
            sort(nums1.begin(),nums1.end());
        }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.