Preview:
class Solution {
public:
    vector<string> twoEditWords(vector<string>& q, vector<string>& d) {
        int n1=d.size();
        int n2=q.size();
        int k=q[0].size();
        vector<string>v;
        set<int> idx;
        for(int i=0;i<n2;i++)
        {
            for(int j=0;j<n1;j++)
            {
                int c=0;
                for(int h=0;h<k;h++)
                {
                    if(d[j][h]!=q[i][h]) c++;
                }
                if(c<=2) idx.insert(i);
            }
        }
        for(auto x:idx)
        {
           v.push_back(q[x]) ;
        }
        return v;
    }
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter