Skip to main content

3330.js

/** ------------------------------------------------------------------------------
*
* 3330. Find the Original Typed String I
* Topics: String
* https://leetcode.com/problems/find-the-original-typed-string-i/description/?envType=daily-question&envId=2025-07-01
*
------------------------------------------------------------------------------ */
/**
* @param {string} word
* @return {number}
*/
var possibleStringCount = function (word) {
let res = 1
let i = 0,
l = word.length,
val = 0,
cur
while (i < l) {
;(val = 1), (cur = word[i])
while (i < l - 1 && cur === word[i + 1]) {
val++
i++
}
i++
res += val - 1
}
return res
}

console.log(possibleStringCount("abbcccc"))