C++ || Best and Easiest Solution || Monotonic Stack || vector merging
Approach\nTake ans = 0;\nfor every i from 0 to n-1, do the following : \n1. Take max number of i digits from nums1 and max number of k-i digits from nums2.\n2. 
# Approach\nTake ans = 0;\nfor every i from 0 to n-1, do the following : \n1. Take max number of i digits from nums1 and max number of k-i digits from nums2.\n2. Merge the above generated numbers to get the maximum number temp of k digits.\n3. update our ans as ans = max(ans , temp);\n\n\n# Code\n```\nclass Solution {\npublic:\n\n    // function to generate maximum number of k digits in the form of vector obtained using elements of array nums.\n    vector<int> solve(int k , vector<int> &nums){\n        int n = nums.size();\n        if(k>n) return {};\n        vector<int> ans;\n        int rem = n-k;\n        ans.push_back(nums[0]);\n        // monotonic stack\n        for(int i=1 ; i<n ; i++){\n            while(!ans.empty() && nums[i]>ans.back() && rem>0){\n                ans.pop_back();\n                rem--;\n            }\n            ans.push_back(nums[i]);\n        }\n        while(rem--){\n            ans.pop_back();\n        }\n        return ans;\n    }\n\n    // function to merge two numbers in the form of vectors (v1 and v2) to get the maximum possible number and store it in another vector temp\n    void merge(vector<int> &ans , vector<int> &v1 , vector<int> &v2){\n        int m = v1.size();\n        int n = v2.size();\n        int i=0;\n        int j=0;\n        \n        while(i<m && j<n){\n            // Case1:\n            // ....5 5 5 5 5 7....     .... 5 5 5 5 5 5...\n            //     i                        j\n            //               tempi                     tempj\n            if(v1[i] == v2[j]){\n                int tempi= i;\n                int tempj= j;\n                while(tempi<m && tempj<n && v1[tempi]==v2[tempj]){\n                    tempi++;\n                    tempj++;\n                }\n                if(tempj == n){\n                    ans.push_back(v1[i]);\n                    i++;\n                }else if(tempi == m){\n                    ans.push_back(v2[j]);\n                    j++;\n                }else if(v1[tempi]>v2[tempj]){\n                    ans.push_back(v1[i]);\n                    i++;\n                }else{\n                    ans.push_back(v2[j]);\n                    j++;\n                }                \n            }\n            // Case2 : ....5 6 7 3 4.....     .....2 3 9 8 7....\n            //             i                       j\n            else if(v1[i] > v2[j]){\n                ans.push_back(v1[i]);\n                i++;\n            }\n            // Case2 : ....2 6 7 3 4.....     .....9 3 9 8 7....\n            //             i                       j\n            else{\n                ans.push_back(v2[j]);\n                j++;\n            }\n        }\n        // if ......8 9 7   ...3 5 2 8\n        //          i                j\n        while(i<m){\n            ans.push_back(v1[i]);\n            i++;\n        }\n        // if ......8 9 7   ...3 5 2 8\n        //              i      j\n        while(j<n){\n            ans.push_back(v2[j]);\n            j++;\n        }\n    }\n\n    vector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, int k) {\n        // We consider every possible case:\n        // eg.1 Take maximum number of 0 digits from nums1 and maximum number of k digits from nums2 and merge them to get a maximum number of k digits.\n        // eg2. Take maximum number of 1 digits from nums1 and maximum number of k-1 digits from nums2 and merge them to get a maximum number of k digits.\n        // eg3. Take maximum number of 2 digits from nums1 and maximum number of k-2 digits from nums2 and merge them to get a maximum number of k digits.\n        // eg4. Take maximum number of 3 digits from nums1 and maximum number of k-3 digits from nums2 and merge them to get a maximum number of k digits.\n        // and so on.................\n        // Then take the maximum among all the above generated numbers as our answer.\n\n        vector<int> ans;\n        for(int i=0 ; i<=k ; i++){\n            vector<int> temp1 = solve(i , nums1);\n            vector<int> temp2 = solve(k-i , nums2);\n            vector<int> temp;\n            merge(temp , temp1 , temp2);\n            if(temp.size() == k) ans = max(ans , temp);\n        }\n        return ans;\n    }\n};\n```\n\n**Upvote if you understood the approach and the code!**
['C++']