Run-length compression
Easystringtwo pointers
Write each run of identical letters as the letter followed by its count, or just the letter when the count is 1. For example aaabcc becomes a3bc2.
Example 1
Input: s = "aaabcc" Output: "a3bc2"
Example 2
Input: s = "abc" Output: "abc"
Constraints
- 1 ≤ s.length ≤ 10⁴
- Lowercase letters
Submit checks your solution against 9 tests, including hidden ones.
/**
* @param {string} s
* @return {string}
*/
function compress(s) {
}