3163. String Compression III
Given a string word, compress it using the following algorithm: - Begin with an empty string comp. While word is not empty, use the following operation: - Remove a maximum length prefix of word made of a single character c repeating at most 9 times. - Append the length of the prefix followed by c to comp. Return the string comp. Example 1: Input: word = "abcde" Output: "1a1b1c1d1e" E
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start