Skip to content

Instantly share code, notes, and snippets.

@ocean-tm
ocean-tm / string-compression-iii.js
Created May 26, 2026 11:03
Solved with JS (reduce-based approach)
/**
* @param {string} word
* @return {string}
*/
var compressedString = function(word) {
if (word.length < 1 || word.length > (2 * 10 ** 5)) {
return null
}
if (!/^[a-z]+$/.test(word)) {