✅ C++ | DYNAMIC PROGRAMMING SOLUTION
Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \nO(nm)\n- Space complexity:\n Add your space complexity here, e.g. O(n) \nO(nm)\n# Co
# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(nm)$$\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(nm)$$\n# Code\n```\nclass Solution {\npublic:\n    string findMaxNum(vector<int>& nums1, vector<int>& nums2, int k, int x, int y, vector<vector<string>>& dp) {\n        if (k == 0) return "";\n        if (!dp[x][y].empty()) return dp[x][y];\n        string res = "";\n        int idx1 = x, idx2 = y, upperBound1 = nums2.size() + nums1.size() - y - k, upperBound2 = nums2.size() + nums1.size() - x - k;\n        if (upperBound1 > nums1.size() - 1) upperBound1 = nums1.size() - 1;\n        if (upperBound2 > nums2.size() - 1) upperBound2 = nums2.size() - 1;\n        for (int i = x; i <= upperBound1; ++ i) if (nums1[i] > nums1[idx1]) idx1 = i;\n        for (int i = y; i <= upperBound2; ++ i) if (nums2[i] > nums2[idx2]) idx2 = i;\n        if (idx1 < nums1.size() && idx2 < nums2.size()) {\n            if (nums1[idx1] >= nums2[idx2]) res = to_string(nums1[idx1]) + findMaxNum(nums1, nums2, k - 1, idx1 + 1, y, dp);\n            if (nums1[idx1] <= nums2[idx2]) res = max(res, to_string(nums2[idx2]) + findMaxNum(nums1, nums2, k - 1, x, idx2 + 1, dp));\n        } \n        else if (idx1 < nums1.size()) res = to_string(nums1[idx1]) + findMaxNum(nums1, nums2, k - 1, idx1 + 1, y, dp);\n        else if (idx2 < nums2.size()) res = to_string(nums2[idx2]) + findMaxNum(nums1, nums2, k - 1, x, idx2 + 1, dp);\n        dp[x][y] = res;\n        return res;\n\n    }\n\n    vector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, int k) {\n        vector<vector<string>> dp(nums1.size() + 1, vector<string>(nums2.size() + 1));\n        string maxNum = findMaxNum(nums1, nums2, k, 0, 0, dp);\n        vector<int> res;\n        for (char c : maxNum) res.push_back(c - \'0\');\n        return res;\n    }\n};\n```\n**Please upvote if u like the solution :)**
['Dynamic Programming', 'Memoization', 'C++']