Integer to Roman LeetCode solution in Python
1# Runtime: 47 ms (Top 86.4%) | Memory: 16.42 MB (Top 14.9%)234class Solution:5def intToRoman(self, num: int) -> str:6# Creating Dictionary for Lookup7num_map = {81: "I",95: "V",104: "IV",1110: "X",129: "IX",1350: "L",1440: "XL",15100: "C",1690: "XC",17500: "D",18400: "CD",191000: "M",20900: "CM",21}2223# Result Variable24r = ""2526for n in [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]:27# If n in list then add the roman value to result variable28while n <= num:29r += num_map[n]30num -= n31return r