Skip to content
Katabench
Try free

Run-Length Decoded Length

Easy About 8 min Free, no account needed

How long would the decoded string be? Do not decode it to find out.

The brief

Given a run-length encoding, letters each followed by a positive count, like "a12b3", return the length of the decoded string.

The allocation budget

Actually expanding the runs materializes the decoded string just to read its .Length, the hidden encoding decodes to ~10 million characters under a 16 KB allocation budget. You will need to compute the length without ever building the decoded string.

Starter code

C#
using System;

public class Solution
{
    // TODO: return the length of the decoded string for a run-length encoding like "a12b3".
    public long DecodedLength(string rle)
    {
        throw new NotImplementedException();
    }
}

How it is graded

Visible examples help you iterate. Hidden tests then cover edge cases and larger inputs, and every test reports server-measured time and allocated bytes.

C# coding challenges →

What it practices

String processing
Parse, scan and match text character by character with correct edge cases.

Related katas