Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
My code:
class Solution(object):
def intToRoman(self, num):
"""
:type num: int
:rtype: str
"""
numDict = [["","I","II","III","IV","V","VI","VII","VIII","IX"],
["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],
["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],
["","M","MM","MMM"]]
result = ''
result +=numDict[3][num / 1000 % 10]
result +=numDict[2][num / 100 % 10]
result +=numDict[1][num / 10 % 10]
result +=numDict[0][num % 10]
return result