C++ Solution - greedy, monotonic stack
\nclass Solution {\npublic:\n    // pick k numbers from vector num\n    vector<int> select(vector<int>& nums, int k){\n        int n = nums.size();\n        vec
```\nclass Solution {\npublic:\n    // pick k numbers from vector num\n    vector<int> select(vector<int>& nums, int k){\n        int n = nums.size();\n        vector<int> res(k, INT_MIN);\n        for(int i = 0, j = 0;i<nums.size();i++){\n            int x = nums[i];\n            // monotonic stack\n            while(j>0&&x > res[j-1]&&i+k-j<n) j--;\n            if(j<k) res[j++] = x;\n        }\n        return res;\n    }\n    vector<int> merge(vector<int>& a, vector<int> &b){\n        vector<int> c;\n        while(a.size()&&b.size()){\n            // The time complexity of compare operation for two vector is order of n.\n            // Greedy Algorithm:\n            // If we meet two elements which have the same value, choose the vector which has the higher dictionary order first.\n            // 1: ...xxxb , 2: ...xxxa, if a > b, then merge sequence 2 first. \n            if(a > b)\n                c.push_back(a[0]), a.erase(a.begin());\n            else\n                c.push_back(b[0]), b.erase(b.begin());\n        }\n        while(a.size())\n            c.push_back(a[0]), a.erase(a.begin());\n        while(b.size())\n            c.push_back(b[0]), b.erase(b.begin());\n        return c;\n    }\n    vector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, int k) {\n        vector<int> res(k, INT_MIN);\n        int n = nums1.size(), m = nums2.size();\n        // s1  => nums1.size(), s2 => nums2.size()\n        // {0<=i<=k, i<=s1, 0<=k-i<=s2} => i>=max(0, k-s2), i<=min(k, n)\n        for(int i = max(0, k-m);i<=min(k, n);i++){\n            vector<int> a = select(nums1, i);\n            vector<int> b = select(nums2, k - i);\n            res = max(res, merge(a, b));\n        }\n        return res;\n    }\n};\n```\n// yxc nb!
[]