Integer to Roman
I used a dictionary and looped from largest to smallest value. For each value, I keep adding the symbol while it fits in the number and subtracting it.
My mistake was thinking like a list and trying to index the number instead of using a greedy approach.
I used a dictionary and looped from largest to smallest value. For each value, I keep adding the symbol while it fits in the number and subtracting it.
My mistake was thinking like a list and trying to index the number instead of using a greedy approach.