public int romanToInt(String s) {
            if (s == null || s.length() == 0)
                return 0;
            if (s.length() == 1)
                return getNum(s.charAt(0));

            int result = 0;
            for (int i = 0; i < s.length(); i++) {
                if (i < s.length() - 1
                        && getNum(s.charAt(i)) < getNum(s.charAt(i + 1))) {
                    result = result + getNum(s.charAt(i + 1))
                            - getNum(s.charAt(i));
                    i++;
                } else {
                    result += getNum(s.charAt(i));
                }
            }

            return result;
        }