C++ solution
\nclass Solution {\npublic:\n    \nbool compare(vector<int>& nums1, vector<int>& nums2, int start_i, int start_j)\n{\n\tint loop_size = min(nums1.size() - start
```\nclass Solution {\npublic:\n    \nbool compare(vector<int>& nums1, vector<int>& nums2, int start_i, int start_j)\n{\n\tint loop_size = min(nums1.size() - start_i, nums2.size() - start_j);\n\n\tfor (int i = 0; i < loop_size; i++)\n\t{\n\t\tif (nums1[i + start_i] < nums2[i + start_j])\n\t\t\treturn true;\n\t\telse if (nums1[i + start_i] > nums2[i + start_j])\n\t\t\treturn false;\n\t}\n\treturn nums1.size() - start_i < nums2.size() - start_j;\n}\n\nvector<vector<int>> largetsNum(vector<int>& nums)\n{\n\tvector<vector<int>> res;\n\tres.resize(nums.size() + 1);\n\tres.back() = nums;\n\n\tfor (int i = res.size() - 2; i >= 0; i--)\n\t{\t\n\t\tint idx = 0;\n\t\twhile (idx + 1 < res[i + 1].size())\n\t\t{\n\t\t\tif (res[i + 1][idx] < res[i + 1][idx + 1])\n\t\t\t\tbreak;\n\t\t\tidx++;\n\t\t}\n\n\t\tfor (int j = 0; j < res[i + 1].size(); j++)\n\t\t{\n\t\t\tif (idx != j)\n\t\t\t\tres[i].push_back(res[i + 1][j]);\n\t\t}\n\t}\n\treturn res;\n}\n\nvector<int> merge(vector<int>& nums1, vector<int>& nums2)\n{\n\tvector<int> res;\n\tint i = 0, j = 0;\n\twhile (i < nums1.size() || j < nums2.size())\n\t{\n\t\t\tif (compare(nums1, nums2, i, j))\n\t\t\t\tres.push_back(nums2[j++]);\n\t\t\telse\n\t\t\t\tres.push_back(nums1[i++]);\n\t}\n\treturn res;\n}\n\nvector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, size_t k) \n{\n\tvector<vector<int>> largest_num1 = largetsNum(nums1);\n\tvector<vector<int>> largest_num2 = largetsNum(nums2);\n\n\tvector<int> res;\n\n\tint start = k > nums2.size() ? k - nums2.size() : 0;\n\n\tfor (int i = start; i < largest_num1.size() && i <= k; i++)\n\t{\n\t\tvector<int> tmp = merge(largest_num1[i], largest_num2[k - i]);\n\t\tif (res.empty() || compare(res, tmp, 0, 0))\n\t\t\tres = tmp;\n\t}\n\n\treturn res;\n}\n};\n```
[]