2019-01-21 LeetCode - Algorithms - 13. Roman to Integer Java JAVA—————-Easy Version To Understand!!!! 12345678910111213141516171819202122232425class Solution { public int romanToInt(String s) { if (s==null || s.isEmpty()) return -1; Map<Character, Integer> map = new HashMap<Character, Integer>(); map.put('I',1); map.put('V',5); map.put('X',10); map.put('L',50); map.put('C',100); map.put('D',500); map.put('M',1000); char[] arr = s.toCharArray(); int len = arr.length; int sum = map.get(arr[len-1]); for(int i=0;i<len-1;i++) { if (map.get(arr[i])>=map.get(arr[i+1])) { sum += map.get(arr[i]); } else { sum -= map.get(arr[i]); } } return sum; }} Submission Detail 3999 / 3999 test cases passed. Runtime: 91 ms Your runtime beats 20.92 % of java submissions. Newer LeetCode - Algorithms - 26. Remove Duplicates from Sorted Array Older LeetCode - Algorithms - 21. Merge Two Sorted Lists