C++ || BFS  + HASH || T/S O((n1+n2)*k), 98.67% Fast, 89.12% Space || Notes
\nclass Solution {\npublic:\n    vector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, int k) {\n        vector<int> ans(k,0);\n\n        int n1 = nums1
```\nclass Solution {\npublic:\n    vector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, int k) {\n        vector<int> ans(k,0);\n\n        int n1 = nums1.size();\n        int n2 = nums2.size();\n        vector<vector<int>> ind1(n1+1);  // direct pointer for each digit for every ix\n        vector<vector<int>> ind2(n2+1);  // direct pointer for each digit for every ix\n        vector<int> il(10,n1);\n        ind1[n1] = il;\n        int i;\n        for(i=n1-1; i>=0; i--) \n        {  // Starting from the end, update the index for the next for each digit\n            il[nums1[i]]=i;\n            ind1[i] = il;\n        }\n        vector<int> ik(10,n2);\n        ind2[n2] = ik;\n        for(i=n2-1; i>=0; i--) \n        {  // Starting from the end, update the index for the next for each digit\n            ik[nums2[i]]=i;\n            ind2[i]=ik;\n        }\n        int ix = 0;\n        queue<pair<int,int>> q1;  // Double queues system to implement BFS\n        queue<pair<int,int>> q2;\n        queue<pair<int,int>> &q = q1;        // Current queue\n        queue<pair<int,int>> &q_next = q2;   // Next queue\n        q.push({0,0});\n\t\tunordered_map<int,int> hash;         // Hash to avoid duplication\n        while (ix < k)\n        {\n            while(!q.empty())\n            {\n                int ix1 = q.front().first;\n                int ix2 = q.front().second;\n                q.pop();\n                if (hash.count(ix1*512+ix2)) continue;  // Avoid duplication\n                hash[ix1*512+ix2]++;\n                for(int d = 9; d>=ans[ix]; d--)\n                {   // Checking the availebility from high to low (the current highest for this ix)\n                    int i =ind1[ix1][d];\n                    if (i<n1 && n1+n2-ix2-i>=k-ix)    \n                    {\n                        // cout << d << ", " << i << endl;\n                         if (ans[ix] < d) \n                        {  // if better than prev (same ix) clear prev\n                            while(!q_next.empty()) q_next.pop();\n                            ans[ix] = d;\n                        }\n                        q_next.push({i+1,ix2});  // add curent combination\n                        break;\n                    }\n                }\n                for(int d = 9; d>=ans[ix]; d--) \n                {   // Checking the availebility from high to low (the current highest for this ix)\n                    int i =ind2[ix2][d];    // Update the ix for next d (n2 means no next available)\n                    \n                    if (i<n2 && n1+n2-ix1-i>=k-ix)  // Check if this ix allow leave enough digit to get to length k\n                    {  // Yes - \n                        // cout << d << ",," << i << endl;\n                        if (ans[ix] < d)  // Check if new max for this ix. \n                        {   // If new max arase acumulated combination of the old max\n                            while(!q_next.empty()) q_next.pop();\n                            ans[ix] = d;  // Save new max\n                        }\n                        q_next.push({ix1,i+1});  //\xA0Push current combination\n                        break;\n                    }\n                }\n            }\n            swap(q,q_next);  // prepare next queue  (next become current)\n            ix++;\n        }\n        return  ans;   \n    }\n};\n\n```\n// Simple\n```\nclass Solution {\npublic:\n    vector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, int k) {\n        vector<int> ans(k,0);\n\n        int n1 = nums1.size();\n        int n2 = nums2.size();\n        vector<vector<int>> d1(10);\n        vector<vector<int>> d2(10);\n        for(int i=0; i<n1; i++) d1[nums1[i]].push_back(i);\n        for(int i=0; i<n2; i++) d2[nums2[i]].push_back(i);\n        int ix1[10]={0};\n        int ix2[10]={0};\n        int ix = 0;\n        queue<pair<int,int>> q1;\n        queue<pair<int,int>> q2;\n        queue<pair<int,int>> &q = q1;\n        queue<pair<int,int>> &q_next = q2;\n        q.push({0,0});\n        unordered_map<int,int> hash;\n        while (ix < k)\n        {\n            while(!q.empty())\n            {\n                int ix1 = q.front().first;\n                int ix2 = q.front().second;\n                q.pop();\n                if (hash.count(ix1*512+ix2)) continue;  // Avoid duplication\n                hash[ix1*512+ix2]++;\n                for(int d = 9; d>=ans[ix]; d--)\n                {\n                    int i;\n                    for (i=0; i<d1[d].size(); i++) \n                    {\n                        if (d1[d][i] < ix1) continue;\n                        if (n1+n2-ix2-d1[d][i]>=k-ix) break;  // find largest available\n                    }\n                    if (i<d1[d].size())    \n                    {\n                         if (ans[ix] < d) \n                        {  // if better than prev (same ix) clear prev\n                            while(!q_next.empty()) q_next.pop();\n                            ans[ix] = d;\n                        }\n                        q_next.push({d1[d][i]+1,ix2});  // add curent combination\n                        break;\n                    }\n                }\n                for(int d = 9; d>=ans[ix]; d--) \n                {\n                    int i;\n                    for (i=0; i<d2[d].size(); i++) \n                    {\n                        if (d2[d][i] < ix2)continue;\n                        if (n1+n2-ix1-d2[d][i]>=k-ix) break;\n                    }\n                    if (i<d2[d].size())    \n                    {  \n                        if (ans[ix] < d) \n                        {\n                            while(!q_next.empty()) q_next.pop();\n                            ans[ix] = d;\n                        }\n                        q_next.push({ix1,d2[d][i]+1});\n                        break;\n                    }\n                }\n            }\n            swap(q,q_next);  // prepare next queue\n            ix++;\n        }\n        return  ans;\n    }\n};\n\n/*\n[3,4,6,5]\n[9,1,2,5,8,3]\n5\n\n[6,7]\n[6,0,4]\n5\n*/\n```
[]