作者:情商是你弟 | 来源:互联网 | 2023-05-18 06:07
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
这一题和上一题姊妹题~同样的方法,反过来即可,easy~
public class Solution {
public int romanToInt(String s) {
int ans = 0;
int[] aArray = {1000,900,500,400,100,90,50,40,10,9,5,4,1};
String[] rArray = {"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
for(int i = 0; i