Time complexity: O(n)
Space complexity: O(1)
Runtime: 2 ms, faster than 100.00% of Java online submissions for Roman to Integer. Memory Usage: 44.4 MB, less than 86.09% of Java online submissions for Roman to Integer.