Skip to content

Add 13_Roman_To_Integer.cpp to cpp folder#511

Closed
rudrakshtank wants to merge 1 commit intocodedecks-in:masterfrom
rudrakshtank:roman_to_integer_solution
Closed

Add 13_Roman_To_Integer.cpp to cpp folder#511
rudrakshtank wants to merge 1 commit intocodedecks-in:masterfrom
rudrakshtank:roman_to_integer_solution

Conversation

@rudrakshtank
Copy link
Copy Markdown

Description

Problem: Convert a Roman numeral string into its corresponding integer value.

Approach:

  1. Store Roman numeral values in an unordered_map.
  2. Traverse the string from right to left.
  3. If the current numeral’s value is greater than or equal to the previous numeral’s value, add it to the total; otherwise, subtract it.
  4. Update the prev character each iteration.
  5. Return the final computed value.

Time Complexity: O(N), where N is the length of the input string.
Space Complexity: O(1), since only a fixed-size hash map is used.

Have you made changes in README file ?

  • Added problem & solution under correct topic.
  • Specified Space & Time complexity.
  • Specified difficulty level, tag & Note(if any).

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.

  • Test A
  • Test B

Make sure all below guidelines are followed else PR will get Reject:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code so that it is easy to understand
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@welcome
Copy link
Copy Markdown

welcome Bot commented Aug 9, 2025

I can tell this is your first pull request! Thank you I'm so honored. 🎉🎉🎉 I'll take a look at it ASAP!

@rudrakshtank rudrakshtank closed this by deleting the head repository Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant