C++ greedy easy to understand
\nclass Solution {\npublic:\n    vector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, int k) {\n        int n = nums1.size(), m = nums2.size();\n      
```\nclass Solution {\npublic:\n    vector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, int k) {\n        int n = nums1.size(), m = nums2.size();\n        vector<int>res(k, INT_MIN);\n        \n        for(int i=max(0, k-m);i<=min(k, n);i++)\n        {   \n            auto a = maxarray(nums1, i);\n            auto b = maxarray(nums2, k-i);\n            auto c = merge(a, b);\n            res = max(res, c);\n        }\n        return res;\n    }\n    \n    vector<int>maxarray(vector<int>&nums, int k)\n    {\n        vector<int>res(k);\n        int n = nums.size(), j = 0;\n        for(int i=0;i<n;i++)\n        {\n            int x = nums[i];\n            while(j && j + n-i > k && res[j-1] < x) j--;\n            if(j < k) res[j++] = x;\n        }\n        return res;\n    }\n    \n    vector<int>merge(vector<int>&a, vector<int>&b)\n    {\n        vector<int>res;\n        while(a.size() && b.size())\n        {\n            if(a > b) res.push_back(a[0]), a.erase(a.begin());\n            else res.push_back(b[0]), b.erase(b.begin());\n        }\n        while(a.size())\n            res.push_back(a[0]), a.erase(a.begin());\n        while(b.size())\n            res.push_back(b[0]), b.erase(b.begin());\n        return res;\n    }\n};\n```
[]