leetle

Daily challenge for 2026-05-13

498. Compressed String Expansion Sum

You are given a string s consisting of characters and digits. Each digit represents the number of times the character immediately following it should be counted. If a character is not preceded by a digit, it counts as 1. Your task is to return the total length the string would have if fully expanded. All digits are single digits (0-9).

Example:
Input: s = "3a2bc"
Output: 6
(Explanation: "3a" becomes "aaa", "2b" becomes "bb", "c" becomes "c". Total length: 3 + 2 + 1 = 6)

Run this challenge interactively in Python or JavaScript when the app loads.