[C++][Roman To Integer] simple easy to understand solution


#1
int Solution::romanToInt(string A) {
    unordered_map<char, int> umap { {'I', 1}, {'V', 5},     \
                                    {'X', 10}, {'L', 50},   \
                                    {'C', 100}, {'D', 500}, \
                                    {'M', 1000}};
    int val = umap[A[0]];
    for(int i=1; i<A.size(); i++) {
        int cur = umap[A[i]], prev = umap[A[i-1]];
        val += cur;
        if(cur > prev)   val -= prev*2;
    }
    return val;
}