1
var countTexts = function (pressedKeys) {3
const n = pressedKeys.length;4
const dp = new Array(n + 1).fill(0);11
for (let i = 1; i <= n; ++i) {12
const currChar = pressedKeys[i - 1];14
if (currChar != lastChar) repeatCount = 0;19
dp[i] = (dp[i] + dp[i - 1]) % MOD;21
if (i >= 2 && repeatCount >= 2) dp[i] = (dp[i] + dp[i - 2]) % MOD;22
if (i >= 3 && repeatCount >= 3) dp[i] = (dp[i] + dp[i - 3]) % MOD;23
if ((currChar == "7" || currChar == "9") && i >= 4 && repeatCount >= 4)24
dp[i] = (dp[i] + dp[i - 4]) % MOD;