UNION FIND || TIME O(n*n), SPACE O(n*n) || C++
\nclass Solution {\npublic:\n    int find(int x,vector<int> &p){\n        if(p[x]==x)return x;\n        return find(p[x],p);\n    }\n    void unon(int x,int y,v
```\nclass Solution {\npublic:\n    int find(int x,vector<int> &p){\n        if(p[x]==x)return x;\n        return find(p[x],p);\n    }\n    void unon(int x,int y,vector<int> &p,vector<int> &sz){\n        int a = find(x,p);\n        int b = find(y,p);\n        if(a==b)return;\n        if(sz[a]<sz[b]){\n            swap(a,b);\n        }\n        p[b] = a;\n        sz[a] += sz[b];\n    }\n    string findTheString(vector<vector<int>>& lcp) {\n        int i,j,n=lcp.size();\n        vector<int> p(n),sz(n);\n        for(i = 0; i < n; i++){\n            sz[i] = 1;\n            p[i] = i;\n        }\n        for(i = 0; i<n; i++){\n            for(j = 0; j < n; j++){\n                if(lcp[i][j]==0)continue;\n                if(lcp[i][j])unon(i,j,p,sz);//ith and jth char is same if lcp>0 \n                if(i==j&&lcp[i][j] !=n-i)return "";\n            }\n        }\n        unordered_set<int> s;//find all possible disticnt char\n        for(auto &i: p){\n            s.insert(i);\n        }\n        if(s.size()>26)return "";//if no of possible chars > 26 return "";\n        string str = "";\n        unordered_map<int,char> mp;\n        char c = \'a\';\n        for(i = 0; i < n; i++){\n            if(mp.count(p[i])==0){\n                mp[p[i]] = c++;//assign easch parent to disticnt char\n            }\n            str += mp[p[i]];\n        }\n        vector<vector<int>> dp(n,vector<int> (n,0));//make a lcp by answer string\n        for(i = n-1; i >= 0; i--){\n            for(j = n-1; j>=0; j--){\n                if(str[i] != str[j])dp[i][j] = 0;\n                else{\n                    if(i+1<n&&j+1<n){\n                        dp[i][j] += dp[i+1][j+1]+1;\n                    }else{\n                        dp[i][j] = 1;\n                    }\n                }\n            }\n        }\n        for(i = 0; i < n; i++){\n            for(j=  0; j < n; j++){\n                if(dp[i][j]!=lcp[i][j])return "";//if not same return "";\n            }\n        }\n        return str;\n    }\n};\n```
['Dynamic Programming', 'Greedy', 'Union Find', 'C', 'C++']