Short Python / Ruby / C++
Python\n\n    def maxNumber(self, nums1, nums2, k):\n\n        def prep(nums, k):\n            drop = len(nums) - k\n            out = []\n            for num i
**Python**\n\n    def maxNumber(self, nums1, nums2, k):\n\n        def prep(nums, k):\n            drop = len(nums) - k\n            out = []\n            for num in nums:\n                while drop and out and out[-1] < num:\n                    out.pop()\n                    drop -= 1\n                out.append(num)\n            return out[:k]\n\n        def merge(a, b):\n            return [max(a, b).pop(0) for _ in a+b]\n\n        return max(merge(prep(nums1, i), prep(nums2, k-i))\n                   for i in range(k+1)\n                   if i <= len(nums1) and k-i <= len(nums2))\n\nSolved it on my own but now I see others already posted this idea. Oh well, at least it's short, particularly my `merge` function.\n\nThe last two lines can be combined, but I find it rather ugly and not worth it:  \n`for i in range(max(k-len(nums2), 0), min(k, len(nums1))+1))`\n\n---\n\n**Ruby**\n\n    def prep(nums, k)\n      drop = nums.size - k\n      out = [9]\n      nums.each do |num|\n        while drop > 0 && out[-1] < num\n          out.pop\n          drop -= 1\n        end\n        out << num\n      end\n      out[1..k]\n    end\n    \n    def max_number(nums1, nums2, k)\n      ([k-nums2.size, 0].max .. [nums1.size, k].min).map { |k1|\n        parts = [prep(nums1, k1), prep(nums2, k-k1)]\n        (1..k).map { parts.max.shift }\n      }.max\n    end\n\n---\n\n**C++**\n\nTranslated it to C++ as well now. Not as short anymore, but still decent. And C++ allows different functions with the same name, so I chose to do that here to show how nicely the `maxNumber(nums1, nums2, k)` problem can be based on the problems `maxNumber(nums, k)` and `maxNumber(nums1, nums2)`, which would make fine problems on their own.\n\n    vector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, int k) {\n        int n1 = nums1.size(), n2 = nums2.size();\n        vector<int> best;\n        for (int k1=max(k-n2, 0); k1<=min(k, n1); ++k1)\n            best = max(best, maxNumber(maxNumber(nums1, k1),\n                                       maxNumber(nums2, k-k1)));\n        return best;\n    }\n\n    vector<int> maxNumber(vector<int> nums, int k) {\n        int drop = nums.size() - k;\n        vector<int> out;\n        for (int num : nums) {\n            while (drop && out.size() && out.back() < num) {\n                out.pop_back();\n                drop--;\n            }\n            out.push_back(num);\n        }\n        out.resize(k);\n        return out;\n    }\n\n    vector<int> maxNumber(vector<int> nums1, vector<int> nums2) {\n        vector<int> out;\n        while (nums1.size() + nums2.size()) {\n            vector<int>& now = nums1 > nums2 ? nums1 : nums2;\n            out.push_back(now[0]);\n            now.erase(now.begin());\n        }\n        return out;\n    }\n\nAn alternative for `maxNumber(nums1, nums2)`:\n\n    vector<int> maxNumber(vector<int> nums1, vector<int> nums2) {\n        vector<int> out;\n        auto i1 = nums1.begin(), end1 = nums1.end();\n        auto i2 = nums2.begin(), end2 = nums2.end();\n        while (i1 != end1 || i2 != end2)\n            out.push_back(lexicographical_compare(i1, end1, i2, end2) ? *i2++ : *i1++);\n        return out;\n    }
['Python', 'C++', 'Ruby']