My Solutions
1. Emulate the process\n\n/**\n * Time Complexity: O(n + t)\n * Space Complexity: O(1)\n * where `n` is the length of the string `s`\n */\nclass Solution {\n pu
**1. Emulate the process**\n```\n/**\n * Time Complexity: O(n + t)\n * Space Complexity: O(1)\n * where `n` is the length of the string `s`\n */\nclass Solution {\n public:\n  int lengthAfterTransformations(const string &s, const int t) {\n    constexpr int mod = 1000000007;\n    constexpr int range = 2;\n    constexpr int letters = 26;\n    constexpr char a = \'a\';\n    int letter_to_count[range][letters]{};\n    int previous = 0;\n    int current = 1;\n    for (const char c : s) {\n      ++letter_to_count[previous][c - a];\n    }\n    \n    for (int i = 0; i < t; ++i) {\n      letter_to_count[current][0] = letter_to_count[previous][letters - 1];\n      letter_to_count[current][1] = (letter_to_count[previous][0] + letter_to_count[previous][letters - 1]) % mod;\n      for (int letter = 2; letter < letters; ++letter) {\n        letter_to_count[current][letter] = letter_to_count[previous][letter - 1];\n      }\n      \n      previous ^= 1;\n      current ^= 1;\n      memset(letter_to_count[current], 0, sizeof(letter_to_count[current]));\n    }\n    \n    return static_cast<int>(accumulate(letter_to_count[previous], letter_to_count[previous] + letters, 0LL) % mod);\n  }\n};\n```
[]