标签:des cWeb style blog http io ar os sp
Roman to Integer
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
SOLUTION 1:
思路:
从后往前遍历罗马数字,如果某个数比前一个数小,则把该数在结果中减掉;
反之,则在结果中加上当前这个数;
GITHUB 代码:
https://github.com/yuzhangcmu/LeetCode_algorithm/blob/master/string/RomanToInt.java
LeetCode: Roman to Integer 解题报告
标签:des cWeb style blog http io ar os sp
原文地址:http://www.cnblogs.com/yuzhangcmu/p/4117312.html