We create a map. Then we iterate through our roman word and we construct our decimal number.
Looking into map takes log n time but since we are using map of only 7 entries, the time for using a map should be constant. Then our time complexity of whole program should be O(|S|).
We create a map. Then we iterate through our roman word and we construct our decimal number. Looking into map takes log n time but since we are using map of only 7 entries, the time for using a map should be constant. Then our time complexity of whole program should be O(|S|).