← Discussions on Roman to Integer
S saiaga1
16 Oct 2026, 16:02

Intuition + complexity breakdown for Roman to Integer.

Use a hash map from value to index (or count). For each element check whether its complement is already in the map, then insert it. That makes it O(n) instead of the O(n²) brute force.

1 reply

kunal_61 1 hour, 10 minutes ago

Same idea, but I used a deque. Works fine.

Sign in to reply.