[Java] Try build the string in greedy approach then test
Intuitive\nSay the String is char[] A.\nWhenever lcp[i][j] > 0, then A[i] == A[j].\nWe can use this rule to try insert letters from left, the letter insert shou
# Intuitive\nSay the String is `char[] A`.\nWhenever `lcp[i][j] > 0`, then `A[i] == A[j]`.\nWe can use this rule to try insert letters from left, the letter insert should start from `a` and increments each we need a new letter.\n\n# Complexity\n- Time complexity: $$O(n^3)$$\n\n- Space complexity: $$O(n)$$\n\n# Code\n```\nclass Solution {\n    public String findTheString(int[][] lcp) {\n        char c = \'a\';\n        int n = lcp.length;\n        for (int i = 0; i < n; i++) {\n            if (lcp[i][i] != n - i) return "";\n            for (int j = 1; j < n; j++) if (lcp[i][j] != lcp[j][i]) return "";\n        }\n        char[] output = new char[n];\n        Arrays.fill(output, \'*\');\n        for (int i = 0; i < n; i++) \n            if (output[i] == \'*\') {\n                if (c > \'z\') return "";\n                for (int j = i; j < n; j++) if (lcp[i][j] > 0) {\n                    if (output[j] != \'*\') return "";\n                    output[j] = c;\n                }\n                c++;\n            }\n            else for (int j = i + 1; j < n; j++) if (lcp[i][j] > 0 && output[i] != output[j]) return "";\n        for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) if (lcp[i][j] > 0) {\n            int k = 0;\n            while (i + k < n && j + k < n && output[i + k] == output[j + k]) k++;\n            if (lcp[i][j] != k) return "";\n        }\n        return new String(output);\n    }\n}\n```
['Greedy', 'Java']