Skip to content
Katabench
Try free

Roman to Integer

Easy About 10 min Free, no account needed

Read Roman numerals, subtractive pairs included.

The brief

Convert a valid Roman numeral (I V X L C D M) to an integer. Six subtractive pairs exist: IV IX XL XC CD CM.

The hidden trap

Summing symbol values one at a time reads IX as 11. A symbol smaller than its right neighbor subtracts instead of adds, the visible tests include easy numerals, the hidden ones stack several subtractive pairs.

Starter code

C#
using System;

public class Solution
{
    // TODO: return the value of a Roman numeral.
    public int RomanToInt(string s)
    {
        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