|
3 | 3 | * https://leetcode.com/problems/roman-to-integer/ |
4 | 4 | * Difficulty: Easy |
5 | 5 | * |
6 | | - * Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. |
| 6 | + * Roman numerals are represented by seven different symbols: `I`, `V`, `X`, |
| 7 | + * `L`, `C`, `D` and `M`. |
7 | 8 | * |
8 | 9 | * Symbol Value |
9 | 10 | * I 1 |
|
14 | 15 | * D 500 |
15 | 16 | * M 1000 |
16 | 17 | * |
17 | | - * For example, `2` is written as `II` in Roman numeral, just two one's added together. `12` is written |
18 | | - * as `XII`, which is simply `X + II`. The number `27` is written as `XXVII`, which is `XX + V + II`. |
| 18 | + * For example, `2` is written as `II` in Roman numeral, just two one's |
| 19 | + * added together. `12` is written as `XII`, which is simply `X + II`. |
| 20 | + * The number `27` is written as `XXVII`, which is `XX + V + II`. |
19 | 21 | * |
20 | | - * Roman numerals are usually written largest to smallest from left to right. However, the numeral for |
21 | | - * four is not `IIII`. Instead, the number four is written as `IV`. Because the one is before the five |
22 | | - * we subtract it making four. The same principle applies to the number nine, which is written as `IX`. |
23 | | - * There are six instances where subtraction is used: |
| 22 | + * Roman numerals are usually written largest to smallest from left to right. |
| 23 | + * However, the numeral for four is not `IIII`. Instead, the number four is |
| 24 | + * written as `IV`. Because the one is before the five we subtract it making |
| 25 | + * four. The same principle applies to the number nine, which is written as |
| 26 | + * `IX`. There are six instances where subtraction is used: |
24 | 27 | * |
25 | 28 | * - `I` can be placed before `V (5)` and `X (10)` to make 4 and 9. |
26 | 29 | * - `X` can be placed before `L (50)` and `C (100)` to make 40 and 90. |
|
0 commit comments