Skip to content

Practice Integer to Roman

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#12
LeetCode Problem

Integer to Roman

Problem Statement

Convert num to a standard Roman numeral. Symbols I, V, X, L, C, D, M represent 1, 5, 10, 50, 100, 500, 1000. Process decimal places from greatest to least. The only subtractive pairs are IV, IX, XL, XC, CD, CM, representing 4, 9, 40, 90, 400, 900. I, X, C, M may repeat up to three times; V, L, D cannot repeat. Practice approach: Greedily consume descending values, including the six subtractive pairs, appending their symbols. This prevents invalid abbreviations such as IL for 49. Check boundaries around 4, 9, 40, and 90. The bounded input means output size and running time are bounded.

Source: Integer to Roman on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
num = 2469
Output
"MMCDLXIX"
Explanation

2469 is 2000 + 400 + 60 + 9, rendered as MM + CD + LX + IX.

Constraints

1 <= num <= 3999

Related LeetCode Problems

Practice more problems similar to Integer to Roman.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.