← Discussions on Roman to Integer
D deepikakap7
07 Oct 2026, 17:17

Asked in my Paytm OA last week.

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.

2 replies

krishnahegde 4 days, 21 hours ago

Nice. Got asked a variant of this in an interview.

divya.k 3 days, 11 hours ago

For the TLE: you are rebuilding the list inside the loop, move it outside.

Sign in to reply.