My Solution
\n/**\n * Time Complexity: O(n * n)\n * Space Complexity: O(1)\n * where `n` is the length of the vector `lcp`\n */\nclass Solution {\n public:\n  string findTh
```\n/**\n * Time Complexity: O(n * n)\n * Space Complexity: O(1)\n * where `n` is the length of the vector `lcp`\n */\nclass Solution {\n public:\n  string findTheString(const vector<vector<int>> &lcp) {\n    constexpr char default_c = \'\\0\';\n    constexpr char lower = \'a\';\n    constexpr char upper = \'z\';\n    const int n = static_cast<int>(lcp.size());\n    char candidate = lower;\n    string ret(n, default_c);\n    for (int i = 0; i < n; ++i) {\n      if (ret[i] != default_c) {\n        continue;\n      }\n      if (candidate > upper) {\n        return string{};\n      }\n      ret[i] = candidate++;\n      for (int j = i + 1; j < n; ++j) {\n        if (lcp[i][j] > 0) {\n          ret[j] = ret[i];\n        }\n      }\n    }\n    \n    for (int i = 0; i < n; ++i) {\n      for (int j = 0; j < n; ++j) {\n        const int item = ret[i] == ret[j] ? (i + 1 < n && j + 1 < n ? lcp[i + 1][j + 1] : 0) + 1 : 0;\n        if (item != lcp[i][j]) {\n          return string{};\n        }\n      }\n    }\n    return ret;\n  }\n};\n```
[]