@@ -0,0 +1,1192 @@
+/*%0A * Key point: use switch and make sure how the roman%0A *  numeral works%0A */%0A%0Apublic class Solution %7B%0A    public int romanToInt(String s) %7B%0A        %0A        if(s.length() == 0)%0A            return 0;%0A            %0A        int result = 0;%0A        int current = 0;    //current char's value%0A        int last = 0;   //last char's value%0A%0A        for(int i = 0;i %3C s.length();i++)%7B%0A            switch(s.charAt(i))%7B%0A                case 'M' : current = 1000; break;%0A                case 'D' : current = 500; break;%0A                case 'C' : current = 100; break;%0A                case 'L' : current = 50; break;%0A                case 'X' : current = 10; break;%0A                case 'V' : current = 5; break;%0A                case 'I' : current = 1; break;%0A            %7D%0A            %0A            result += current;%0A            %0A            //test the condition of substractive notation%0A            //such as IX, XL, CD%0A            //first char won't need to be tested%0A            if(i == 0 %7C%7C current %3C= last)%7B%0A                last = current;%0A            %7D%0A            else%7B%0A                result -= last;%0A                result -= last;%0A            %7D%0A        %7D%0A        %0A        return result;%0A    %7D%0A%7D

Roman to Integer