Greedy solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution(object):\n    def findTheString(self, lcp):\n        def nextChar():\n            letter = ord(\'a\') - 1\n            while True:\n                letter += 1\n                yield chr(letter)\n\n        n = len(lcp)\n        res = []\n        charGen = nextChar()\n        for i in range(n):\n            for j in range(i+1):\n                if len(res) != i:\n                    break\n\n                if lcp[i][j]:\n                    if j < i:\n                        res.append(res[j])\n                    else:\n                        res.append( next(charGen) )\n\n            if res and res[-1] > \'z\':\n                return \'\'\n\n        def naiveCheck(i, j):\n            val = 0\n            iSize, jSize = n - i, n - j\n            for k in range(min(iSize, jSize)):\n                ik, jk = i + k, j + k\n                if max(ik, jk) < len(res):\n                    val += res[i+k] == res[j+k]\n            if lcp[i][j] != val:\n                return False\n            return True\n\n        def matrixCheck(i, j):\n            val = 0\n            # if out of the range of res, or the letters at i and j are the same, set to 1\n            if i >= len(res) or j >= len(res) or res[j] == res[i]:\n                val = 1\n                ni, nj = i + 1, j + 1\n                if max(ni, nj) < n:\n                    val +=lcp[ni][nj]\n            if val != lcp[i][j]:\n                return False\n            return True\n\n        for i in range(n):\n            for j in range(n):\n                if not matrixCheck(i, j):\n                    return \'\'\n                    \n        return \'\'.join(res)\n```
['Python']