Simplest solution challenge


#1

public class Solution {
public int romanToInt(String A) {int b=0;
for(int i=A.length()-1;i>=0;i–)
if(i+1!=A.length()&&getA(A.charAt(i+1))>getA(A.charAt(i))) b-=getA(A.charAt(i));
else b+=getA(A.charAt(i));
return b;
}

int getA(char A){
    switch (A) {
        case 'M': return 1000; 
        case 'D': return 500; 
        case 'C': return 100; 
        case 'L': return 50; 
        case 'X': return 10; 
        case 'V': return 5; 
        case 'I': return 1; 
    }
    return 1;
}

}