Problem
Leaderboard
🎁 July Giveaway
This July, you have the opportunity to hone your skills and win the Macbook Air, Sony WH-1000XM4 headphones, $50 gift card and much more.
🎮 How to Play
Complete Educative’s daily coding challenge all month.
Choose your preferred programming language before you start, you can switch it anytime, even mid-problem.
Be mindful of your attempts, you only get a limited number, so make each one count.
Keep your streak alive, the longer it runs, the more raffle entry tickets you rack up.
Earn tickets and increase your chances of winning the draw.
🎟️ How to earn Tickets
ActionTickets Earned
Complete Daily Challenge
+1
10-Day Streak
+10
20-Day Streak
+20
30-Day Streak
+30
LinkedIn post with #30DaysofCode Everyday (and tag Educative)
+2 per post
Most-Liked Post Overall
+20
Top of Leaderboard
+50
Leaderboard: 2nd place
+30
Leaderboard: 3rd place
+20

Problem: Integer to Roman

Statement

Given an integer, num, convert it to its Roman numeral representation.

Roman numerals are built using the following 77 symbols:

Symbol

Value

I

1

V

5

X

10

L

50

C

100

D

500

M

1000

Roman numerals are constructed by converting each decimal place value from highest to lowest using these rules:

  • If the value does not start with 44 or 99, select the largest symbol whose value can be subtracted from the current value, append it to the result, subtract its value, and repeat for the remainder.

  • If the value starts with 44 or 99, use its subtractive form: one smaller symbol placed before a larger one. Only the following subtractive forms are valid: 44 (IV), 99 (IX), 4040 (XL), 9090 (XC), 400400 (CD), and 900900 (CM).

  • Only powers of 1010 ( I, X, C, M ) may be repeated consecutively, and at most 33 times. The symbols V, L, and D may never be repeated. If a symbol would need to appear 44 times, use the corresponding subtractive form instead.

Note: Conversion is applied digit by digit based on decimal place values. For example, 4949 is not treated as 11 less than 5050; instead, 4040 becomes XL and 99 becomes IX.

Constraints:

  • 11 \leq num 3999\leq 3999

Problem
Leaderboard
🎁 July Giveaway
This July, you have the opportunity to hone your skills and win the Macbook Air, Sony WH-1000XM4 headphones, $50 gift card and much more.
🎮 How to Play
Complete Educative’s daily coding challenge all month.
Choose your preferred programming language before you start, you can switch it anytime, even mid-problem.
Be mindful of your attempts, you only get a limited number, so make each one count.
Keep your streak alive, the longer it runs, the more raffle entry tickets you rack up.
Earn tickets and increase your chances of winning the draw.
🎟️ How to earn Tickets
ActionTickets Earned
Complete Daily Challenge
+1
10-Day Streak
+10
20-Day Streak
+20
30-Day Streak
+30
LinkedIn post with #30DaysofCode Everyday (and tag Educative)
+2 per post
Most-Liked Post Overall
+20
Top of Leaderboard
+50
Leaderboard: 2nd place
+30
Leaderboard: 3rd place
+20

Problem: Integer to Roman

Statement

Given an integer, num, convert it to its Roman numeral representation.

Roman numerals are built using the following 77 symbols:

Symbol

Value

I

1

V

5

X

10

L

50

C

100

D

500

M

1000

Roman numerals are constructed by converting each decimal place value from highest to lowest using these rules:

  • If the value does not start with 44 or 99, select the largest symbol whose value can be subtracted from the current value, append it to the result, subtract its value, and repeat for the remainder.

  • If the value starts with 44 or 99, use its subtractive form: one smaller symbol placed before a larger one. Only the following subtractive forms are valid: 44 (IV), 99 (IX), 4040 (XL), 9090 (XC), 400400 (CD), and 900900 (CM).

  • Only powers of 1010 ( I, X, C, M ) may be repeated consecutively, and at most 33 times. The symbols V, L, and D may never be repeated. If a symbol would need to appear 44 times, use the corresponding subtractive form instead.

Note: Conversion is applied digit by digit based on decimal place values. For example, 4949 is not treated as 11 less than 5050; instead, 4040 becomes XL and 99 becomes IX.

Constraints:

  • 11 \leq num 3999\leq 3999