Given a run-length encoded string in the format "char+count" pairs, decode it to the original string by repeating each character the specified number of times. The encoded string contains alternating characters and their counts (e.g., "a3b2c1" means 3 a's, 2 b's, and 1 c).
Return null for null input and empty string for empty input.
Examples:
Input: encoded = "a3b2c1"
Output: "aaabbc"
Explanation: Decode to 3 a's, 2 b's, and 1 c
Input: encoded = "x5"
Output: "xxxxx"
Explanation: Decode to 5 x's
Input: encoded = "a1b1c1"
Output: "abc"
Explanation: Each character appears once
Input: encoded = null
Output: null
Explanation: Return null for null input
Input: encoded = ""
Output: ""
Explanation: Return empty string for empty input
Apex Code Editor
Welcome to Lightning Challenge!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay Mar 2026
Contest runs March 3 - 31. Complete challenges to climb the leaderboard!
Points are calculated for challenges completed during the contest period.