LeetCode problem #13 — Roman to integer (JavaScript)

Solution: Loop with an object (hashmap)

For this super simple solution, we loop through the characters of the provided string, and for each one we check whether that character is worth more or less than the next one (if the next one exists).

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Duncan McArdle

Duncan McArdle

Full-stack software developer from the UK, author of the Aftermath book series, full time tech-nerd.