public int romanToInt(String s) {
        Map<Character, Integer> map = buildMap();
        //MCMLIV -> 1954
        int result = 0;
        int i = 0;
        while(i < s.length()){
            Character curr = s.charAt(i);
            if(i == s.length() - 1){
                result += map.get(curr);
                break;
            }
            Character next = s.charAt(i + 1);
            if(map.get(curr) < map.get(next)){
                result += map.get(next) - map.get(curr);
                i += 2;
            }else{
                result += map.get(curr);
                i++;
            }
        }
        return result;
    }