C++  implementation of the top voted answer without the compare function
class Solution {\n    private:\n        //get the max k-length number of array nums ...\n        vector<int> helper(vector<int>& nums, int k){\n            int 
    class Solution {\n    private:\n        //get the max k-length number of array nums ...\n        vector<int> helper(vector<int>& nums, int k){\n            int n=nums.size();\n            int j=0; // the count of the stacked array \n            vector<int> result(k,0);\n            for(int i=0; i<n; i++){\n                //result[j-1] stores the top of the stack \n                while(j>0 && n-i+j>k && nums[i]>result[j-1])  j--;\n                if(j<k) result[j++]=nums[i];\n            }\n            return result;\n        }\n        \n        vector<int> merge(vector<int>& nums1, vector<int>& nums2, int k){\n            vector<int> result(k, 0);\n            ostringstream num_str1, num_str2;\n            string str1, str2;\n            for(auto num:nums1)  num_str1 << num;\n            for(auto num:nums2)  num_str2 << num;\n            str1=num_str1.str();\n            str2=num_str2.str();\n            for(int i=0, j=0, r=0; r<k; r++){\n                result[r] = str1.substr(i).compare(str2.substr(j)) > 0 ? nums1[i++] : nums2[j++];\n            }\n            return result;\n        }\n        \n    public:\n        vector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, int k) {\n            int n=nums1.size(), m=nums2.size();\n            vector<int> result(k, 0);\n            string result_str;\n            for(int i=max(0, k-m); i<=k && i<=n; i++){\n                vector<int> sub_1 = helper(nums1, i);\n                vector<int> sub_2 = helper(nums2, k-i);\n                vector<int> candidate = merge(sub_1, sub_2, k);\n                ostringstream str_c;\n                for(auto number:candidate)  str_c << number;\n                if(result_str=="" || str_c.str().compare(result_str) > 0 ){\n                    result_str=str_c.str();\n                    result=candidate;\n                }\n            }\n            return result;\n        }\n    };
['C++']