Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

49. Integer to Roman

MediumDay 15 of 60Strings

Given an integer num between 1 and 3999, return its Roman numeral. Use the standard symbols I, V, X, L, C, D, M and the six subtractive forms IV, IX, XL, XC, CD, CM, always choosing the form that uses the largest possible symbols first (so 4 is IV, not IIII).

Example 1
Input: num = 3749
Output: "MMMDCCXLIX"
3000 = MMM, 700 = DCC, 40 = XL, 9 = IX.
Example 2
Input: num = 58
Output: "LVIII"
50 = L, 5 = V, 3 = III.
Constraints
  • 1 <= num <= 3999
Hints
Frequently asked at: Amazon, Microsoft, Adobe, Bloomberg
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min