Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
解法1:O(N) Time
Roman to Integer 是较容易的。需要记忆的是几个关键的Roman字母和数值的对应关系。
从后往前扫描,如果前面的数值比后面的数值小,则需要减去,否则加上。123| I | V | X | L | C | D | M ||---|---|----|---|---|---|--- || 1 | 5 | 10 |50 |100|500|1000|
C++
|
|
|
|