leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0088.cpp (322B)


      1 class Solution {
      2   public:
      3     void merge(vector<int> &nums1, int m, vector<int> &nums2, int n) {
      4         int i = m - 1, j = n - 1, k = m + n - 1;
      5 
      6         while (i >= 0 && j >= 0)
      7             nums1[k--] = nums1[i] > nums2[j] ? nums1[i--] : nums2[j--];
      8         while (j >= 0)
      9             nums1[k--] = nums2[j--];
     10     }
     11 };