/** * Created by kwo2002 on 2015-08-03. */ object ZipString { def zipString(str: String): String = { def go(n: Int, cnt: Int, zipString: StringBuilder): String = { if (cnt == 1) { zipString.append(str.charAt(n)) } if (n >= str.length - 1) { if (cnt > 1) { zipString.append(cnt) } zipString.toString() } else { if (str.charAt(n) == str.charAt(n + 1)) { go(n + 1, cnt + 1, zipString) } else { if (cnt..