LeetCode: Regular Expression Matching 解题报告

小咪咪 2022-03-28 15:44 265阅读 0赞

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:

思路:

从后往前遍历罗马数字,如果某个数比前一个数小,则把该数在结果中减掉;
反之,则在结果中加上当前这个数;

ContractedBlock.gif

GITHUB 代码:

https://github.com/yuzhangcmu/LeetCode_algorithm/blob/master/string/RomanToInt.java

发表评论

表情:
评论列表 (有 0 条评论,265人围观)

还没有评论,来说两句吧...

相关阅读