Concise commented DP+Greedy Soln
\nclass Solution {\npublic:\n    vector single_array(vector& arr1,int k)\n    {\n        int n = arr1.size();\n        vector> dp(min(n,k),vector(n,""));//i+1 d
\nclass Solution {\npublic:\n    vector<string> single_array(vector<int>& arr1,int k)\n    {\n        int n = arr1.size();\n        vector<vector<string>> dp(min(n,k),vector<string>(n,""));//i+1 digits and ending at j maintaining ordering\n        vector<string> dp1(min(n,k),""); //max i-digit number formed maintaing ordering\n        \n        for(int j=0;j<n;j++)\n        {\n            dp[0][j].push_back((char)(arr1[j]+\'0\'));\n            dp1[0] = max(dp1[0],dp[0][j]);\n            if(j>0) dp[0][j] = max(dp[0][j],dp[0][j-1]);\n        }\n        \n        for(int i=1;i<dp1.size();i++)\n        {\n            // num of digits required is i+1\n            // we start at i, not before that\n            for(int j=i;j<n;j++)\n            {\n                dp[i][j] = max(dp[i][j],dp[i-1][j-1]+(char)(arr1[j]+\'0\'));\n                dp1[i] = max(dp[i][j],dp1[i]);\n                if(j>i) dp[i][j] = max(dp[i][j],dp[i][j-1]); \n                // beware : max on strings works as expected when both strings are of same size\n            }\n        }\n        return dp1;\n        \n    }\n    \n    string merge(string r1,string r2)\n    {\n        string fin = "";\n        int n = r1.size();\n        int m = r2.size();\n        int p1 = 0;\n        int p2 = 0;\n        while(p1<n && p2<m)\n        {\n            if(r1[p1]>r2[p2])\n            {\n                fin.push_back(r1[p1]);\n                p1++;\n            }\n            else if(r1[p1]<r2[p2])\n            {\n                fin.push_back(r2[p2]);\n                p2++;\n            }\n            else\n            {\n                if(r1.substr(p1)>=r2.substr(p2))\n                {\n                    fin.push_back(r1[p1]);\n                    p1++;\n                }\n                else\n                {\n                    fin.push_back(r2[p2]);\n                    p2++;\n                }\n            }\n        }\n        while(p1<n) \n        {\n            fin.push_back(r1[p1]);p1++;\n        }\n        while(p2<m) \n        {\n            fin.push_back(r2[p2]);p2++;\n        }\n        return fin;\n    }\n    \n    vector<int> maxNumber(vector<int>& arr1, vector<int>& arr2, int k) \n    {\n        vector<int> ans;\n        int n = arr1.size();\n        int m = arr2.size();\n        if(n==0 && m==0) return ans;\n        if(k==0) return ans;\n        \n        vector<string> dp1 = single_array(arr1,k);\n        vector<string> dp2 = single_array(arr2,k);\n        \n        string an = "";\n        for(int i=0;i<=k;i++)\n        {\n            int sz1 = i;\n            int sz2 = k-i;\n            if(sz1==0 && sz2<=m) an = max(an,dp2[sz2-1]);\n            else if(sz2==0 && sz1<=n) an = max(an,dp1[sz1-1]);\n            else if(sz1<=n && sz2<=m) an = max(an,merge(dp1[sz1-1],dp2[sz2-1]));\n        }\n        \n        \n        for(auto c:an) ans.push_back(c-\'0\');\n        return ans;\n        \n    }\n};
[]