Integer to Roman Problem

Integer to Roman Problem — ExecCode Easy DSA Practice

Solve the Integer to Roman problem on ExecCode. Free online easy DSA practice in Math. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an integer, convert it to a Roman numeral. Your task is to seven different symbols represent Roman numerals with the following values: Roman numerals are formed by appending the conversions of decimal place values from highest to lowest. Converting a decimal place value into a Roman numeral has the following rules: - If the value does not start with 4 or 9, select the symbol of the maximal value that can be subtracted from the input, append that symbol to the result, subtract its value, and convert the remainder to a Roman numeral. Return the required answer exactly as shown in the examples.

Examples

Input {"n": 3}; Output III. Input {"n": 58}; Output LVIII. Input {"n": 1994}; Output MCMXCIV

Constraints

1 <= num <= 3999

Practice Integer to Roman free on ExecCode. Browse DSA problems, topic map, and placement guides.