Python icon indicating copy to clipboard operation
Python copied to clipboard

Leetcode Integer to Roman

Open yashasvimisra2798 opened this issue 4 years ago • 1 comments
trafficstars

Provide solution for problem no. 12 on Leetcode Integer to Roman: https://leetcode.com/problems/integer-to-roman/

yashasvimisra2798 avatar Oct 24 '21 09:10 yashasvimisra2798

'''def intToRoman(self, num: int) -> str: mem = [[1000, 'M'], [900, 'CM'], [500, 'D'], [400, 'CD'], [100, 'C'], [90, 'XC'], [50, 'L'], [40, 'XL'], [10, 'X'], [9, 'IX'], [5, 'V'], [4, 'IV'], [1, 'I']] ret = "" for k in range(len(mem)): while num >= mem[k][0]: num -= mem[k][0] ret += mem[k][1] return ret'''

code of above problem

saurabhjain17 avatar Oct 24 '21 11:10 saurabhjain17