Decimal to Roman
Given an integer n, return its canonical Roman numeral representation. Roman numerals use I, V, X, L, C, D, and M, including the subtractive pairs IV, IX, XL,…
Given an integer `n`, return its canonical Roman numeral representation. Roman numerals use `I`, `V`, `X`, `L`, `C`, `D`, and `M`, including the subtractive pairs `IV`, `IX`, `XL`, `XC`, `CD`, and `CM`. Return uppercase symbols with no spaces.
- `1 <= n <= 3999` - Return the unique canonical Roman numeral for `n`.
Example 1: input n = 58; output "LVIII". 58 decomposes as 50 + 5 + 1 + 1 + 1.
Example 2: input n = 1994; output "MCMXCIV". 1994 decomposes canonically as 1000 + 900 + 90 + 4.
Category: Math & Numbers. Topic: math. Difficulty: Easy. Patterns: greedy, math.