Roman To Integer InterviewBit Solution
- illuminati
- May 24, 2021
- 1 min read
Problem: Roman To Integer
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++:
Recent Posts
See AllGiven an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target.
Given a string A of parantheses ‘(‘ or ‘)’. The task is to find minimum number of parentheses ‘(‘ or ‘)’ (at any positions) we must add to
Comments