LeetCode-Solutions
LeetCode-Solutions copied to clipboard
Add 13_Roman_To_Integer.cpp to cpp folder
Description
Problem: Convert a Roman numeral string into its corresponding integer value.
Approach:
- Store Roman numeral values in an
unordered_map. - Traverse the string from right to left.
- 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.
- Update the
prevcharacter each iteration. - 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 ?
- [x] Added problem & solution under correct topic.
- [x] 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:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code so that it is easy to understand
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] Any dependent changes have been merged and published in downstream modules
I can tell this is your first pull request! Thank you I'm so honored. :tada::tada::tada: I'll take a look at it ASAP!