Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def intToRoman(self, num):
- """
- :type num: int
- :rtype: str
- """
- # Symbol Value
- # I 1
- # V 5
- # X 10
- # L 50
- # C 100
- # D 500
- # M 1000
- dict = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]
- nums = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
- result = ""
- for letter, n in zip(dict, nums):
- result += letter * int(num / n)
- num %= n
- return result
Add Comment
Please, Sign In to add comment