Integer to Roman
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Roman numerals are written using seven symbols, each standing for a fixed value:
| Symbol | Value |
| ------ | ----- |
| I | 1 |
| V | 5 |
| X | 10 |
| L | 50 |
| C | 100 |
| D | 500 |
| M | 1000 |
Most numbers are formed by placing symbols from largest to smallest and adding their values together. For example, 27 is written as XXVII, which is 10 + 10 + 5 + 1 + 1.
There is one twist: a smaller symbol may be placed immediately before a larger one to indicate **subtraction**. This handles the six cases where a digit would otherwise need four repeated symbols:
- I before V (4) or before X (9)
- X before L (40) or before C (90)
- C before D (400) or before M (900)
Given an integer num, convert it to its Roman numeral string. The result should use the standard, shortest valid representation.
Examples
Constraints
- `1 <= num <= 3999`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.