Given a Roman numeral, convert it to an integer.
Input is guaranteed to being within the range from 1 to 3999.
Solution:
Basic characters |
I |
V |
X |
L |
C |
D |
M |
The corresponding Arabic numerals are expressed as |
1 |
5 |
10 |
50 |
100 |
500 |
1000 |
- Single digit examples ⅰ-1, ⅱ-2, ⅲ-3, ⅳ-4, ⅴ-5, ⅵ-6, ⅶ-7, Ⅷ-8, ⅸ-9
- 10-digit examples ⅹ-10, ⅺ-11, ⅻ-12, XIII-13, XIV-14, XV-15, XVI-16, XVII-17, XVIII-18, XIX-19, XX-20, XXI-21, XXII-22, XXIX-29, XXX-30, XXXIV-34, XXXV-35, XXXIX-39, XL-40, L-50, LI-51, LV-55, LX-60, LXV-65, LXXX-80, XC-90, XCIII-93, XCV-95, XCVIII-98, XCIX-99
- examples of hundred C-100, CC-200, CCC-300, CD-400, D-500, DC-600, DCC-700, DCCC-800, CM-900, CMXCIX-999
- Thousands of examples M-1000, MC-1100, MCD-1400, MD-1500, MDC-1600, MDCLXVI-1666, MDCCCLXXXVIII-1888, MDCCCXCIX-1899, MCM-1900, MCMLXXVI-1976 , MCMLXXXIV-1984, MCMXC-1990, MM-2000, MMMCMXCIX-3999
"Leetcode" 6-roman to Integer