Leetcode, Roman To Integer, Scala, Programming, Algorithms.
Array.fill(256)(0) values('I') = 1; values('V') = 5; values('X') = 10; values('L') = 50 values('C') = 100; values('D') = 500; values('M') = 1000 for (c <- s) { val currentValue = values(c) sum += (if (currentValue > prevValue) currentValue - 2 * prevValue else currentValue) prevValue = currentValue