Integer to Roman
Given an integer between 1 and 3999, return its Roman numeral representation.
Examples
Input: 3
Output: "III"
Input: 1994
Output: "MCMXCIV"
Hints
Start by creating a mapping of integer values to their corresponding Roman numeral symbols, ordered from largest to smallest (e.g., 1000 → "M", 900 → "CM", etc.).
Iterate through the value-symbol pairs, repeatedly subtracting the largest possible value from the input number and appending the corresponding symbol to the result string until the number is reduced to zero.
Handle edge cases by ensuring the algorithm correctly processes subtractive combinations (e.g., 4 → "IV", 9 → "IX") by prioritizing larger values and their subtractive pairs in the mapping.
Related Problems
Integer to Roman
Given an integer between 1 and 3999, return its Roman numeral representation.