Skip to content

Add 13_Roman_To_Integer.cpp to cpp folder #511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rudrakshtank
Copy link

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

Copy link

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!

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