Search⌘ K
AI Features

String Compression

String Compression replaces each run in a character array with its character and, when repeated, its count. Write the result in place and return its new length using constant space.

Statement

Given an array of characters, chars, compress it in place according to the following rules:

  1. Start with an empty string s.

  2. For each group of consecutive repeating characters in chars:

    1. If the group length is 11 ...