top of page

Looking to master object-oriented and system design for tech interviews or career growth?

  • Improve your system design and machine coding skills.

  • Study with our helpful resources.

  • Prepare for technical interviews and advance your career.

**We're in beta mode and would love to hear your feedback.

Writer's pictureilluminati

Roman To Integer InterviewBit Solution



Problem Description:


Given a string A representing a roman numeral. Convert A into an integer.

A is guaranteed to be within the range from 1 to 3999.


Input Format

The only argument given is string A. 

Output Format

Return an integer which is the integer verison of roman numeral string. 

For Example

Input 1:
    A = "XIV"
Output 1:
    14

Input 2:
    A = "XX"
Output 2:
    20

Solution Approach:

The approach to this problem is quite straightforward, you just need to understand how Roman Numeral Systems is assigned to a number.


Time Complexity:

We are iterating the string only, so time complexity would be O(N)


Solution in C++:


Kommentare


bottom of page