Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
rudrakshtank wants to merge1 commit intocodedecks-in:master
base:master
Choose a base branch
Loading
fromrudrakshtank:roman_to_integer_solution

Conversation

@rudrakshtank
Copy link

Description

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

Approach:

  1. Store Roman numeral values in anunordered_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 theprev character each iteration.
  5. Return the final computed value.

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

Have you made changes inREADME 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

welcomebot commentedAug 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 freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@rudrakshtank

[8]ページ先頭

©2009-2025 Movatter.jp