(For loop + dp ) solution O(n*n ) approach || c++
Approach\n Describe your approach to solving the problem. \n1. create a dummy vector (v) of same size as of required string having all element \'a\'\n\n2. trave
# Approach\n<!-- Describe your approach to solving the problem. -->\n1. create a dummy vector (v) of same size as of required string having all element \'a\'\n\n2. traverse a lcp array . if : \nlcp[i][j] == 0   ( means v[i] != v[j] )\nbut if in our array (v)  if(v[i] == v[j] ) \nmeans originally we want v[i] != v[j] but they are equal . \nso to make it unequal we increase v[j] .\n\nQues : Why we cannot increase v[j] ? \nAns : we required lexographically smallest string that is only possible if we increase v[j]  ans ( j > i : check for loop 8-9 line from top . )\n\n3. now check if any index of v > \'z\' . means we will not able to assign any alphabet . \nso return "" \n\n4. now try to create or try filling dp . from a answer in vector (v) .\n    ( i , j ) from n-1 to 0 \n    if(v[i] == v[j] ) dp[i][j] = 1 + dp[i+1][j+1] \n\n    and dp[i+1][j+1] is already calculated previously . \n\n4. finally check whether lcp and dp array are equal or not .  \n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO( N * N )\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO( N * N )\n\n# Code\n```\nclass Solution {\npublic:\n    string findTheString(vector<vector<int>>& lcp) {\n        int n = lcp.size() ;\n        int dp[n][n] ;\n        memset(dp , 0 , sizeof(dp)) ;\n        vector<char> v (n , \'a\') ;\n        for(int i = 0 ; i< n ; ++i ){\n            for(int j = i+1 ; j< n ; ++j ){\n                if(lcp[i][j] == 0 && v[i] == v[j] ) {\n                    v[j]++;\n                }\n                if(v[j] > \'z\' ) return "" ;\n            }\n        }\n        for(int i = n-1 ; i>=0 ; --i ){\n            for(int j = n-1 ; j>=0 ; --j ){\n                if(v[i] == v[j] ){\n                    dp[i][j] = 1 ;\n                    if( i + 1 < n && j+1 < n )\n                    dp[i][j] += dp[i+1][j+1] ;\n                }\n            }\n        }\n        for(int i = 0 ; i< n ; ++i ){\n            for(int j = 0 ; j< n ; ++j ){\n                if(lcp[i][j] != dp[i][j] ){\n                    return "" ;\n                } \n            }\n        }\n        string ans = "" ;\n        for(auto it : v ) ans += it ;\n        return ans ; \n    }\n};\n```
['Dynamic Programming', 'Greedy', 'C++']