首页 > 代码库 > [LeetCode]Roman to Integer

[LeetCode]Roman to Integer

题目:给定一串罗马数字,要求将罗马数字转换为十进制数字

算法:

从右往左计算:

1. 若右边<=左边,则作加法

2. 若右边>左边,则作减法

 /**
	 * Calculate from right to left. following the rules below:
	 * 1. if right <= left, then result := right+left
	 * 2. or result := abs(result-left)
	 * 
	 * @author ouyangyewei
	 */
	public class Solution {
	    public int romanToInt(String s) {
	        final String ROMAN_STRING = "IVXLCDM";
	        final int[] ROMAN_VALUE = http://www.mamicode.com/new int[]{1,5,10,50,100,500,1000};>