//easy cpp solution//


#1

int Solution::romanToInt(string A) {
int i;
vectorv;
for(i=0;i<A.length();i++){
if(A[i]==‘I’){
v.push_back(1);
}
if(A[i]==‘V’){
v.push_back(5);
}
if(A[i]==‘X’){
v.push_back(10);
}
if(A[i]==‘L’){
v.push_back(50);
}
if(A[i]==‘C’){
v.push_back(100);
}
if(A[i]==‘D’){
v.push_back(500);
}
if(A[i]==‘M’){
v.push_back(1000);
}
}
int sum=v[v.size()-1];
for(i=v.size()-1;i>=0;i–){
if(v[i]>v[i-1]){
sum=sum-v[i-1];
}
else{
sum=sum+v[i-1];
}
}
return sum;
}