Skip to content

Add cpp solution Roman to Integer (LeetCode Problem 13) #508

@rudrakshtank

Description

@rudrakshtank

Issue Proposal: Roman to Integer (LeetCode Problem 13)

Description

I would like to contribute an optimized and efficient C++ solution for the problem Roman to Integer (LeetCode Problem 13).

Plan of Contribution

  • Implement a clean and readable C++ solution.
  • Time complexity: O(n)
  • Space complexity: O(1)
  • Use an unordered_map<char, int> to store Roman numeral values.
  • Traverse the string from right to left:
    • If the current numeral is less than the previous one, subtract it.
    • Else, add it.
  • Include meaningful comments and example test cases.

Example Output

For input: "MCMXCIV"
The output will be: 1994

Request

Please let me know if this contribution is acceptable and if there's a preferred folder structure or coding style I should follow.

Looking forward to your response! ✨

Thanks,
Rudraksh (GitHub: @rudrakshtank)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions