FastPrepRoman to Integer
Problems/Roman to Integer

Roman to Integer

Navan logoNavan● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Navan phone screen for a new grad role. Our version follows the reported exercise. The report leaves out some input limits and interface details, and we filled those in.

Our version is about 95% the same as the reported question.

You are given a string roman. It is an integer from 1 through 3999 written in standard uppercase Roman numerals. Return the integer it stands for.

Most symbols just add their value. A smaller symbol placed right before a larger one is subtracted instead. The pairs that subtract are IV, IX, XL, XC, CD, and CM.

Function

romanToInteger(roman: String) → int

Examples

Example 1

roman = "III"return = 3

Each I is worth one, and no smaller symbol comes before a larger one. Adding one three times gives three.

Example 2

roman = "IV"return = 4

I comes right before the larger V, so it is subtracted. Five minus one gives four.

Example 3

roman = "IX"return = 9

I comes right before the larger X, so it is subtracted. Ten minus one gives nine.

Constraints

  • 1 <= roman.length <= 15.
  • roman is a value from 1 through 3999 written in standard uppercase Roman numerals.

More Navan interview questions

  • Sort ColorsPHONE SCREEN · Seen Oct 2024
  • Basic CalculatorPHONE SCREEN · Seen Jun 2024
  • LRU CachePHONE SCREEN · Seen Jun 2024
  • House RobberPHONE SCREEN · Seen May 2024
  • House Robber IIPHONE SCREEN · Seen May 2024
  • Snake-Case Iterator to Camel CasePHONE SCREEN · Seen Feb 2024
  • Lexicographically Largest Distinct-Letter SubsequencePHONE SCREEN · Seen May 2023
  • Time Based Key-Value StoreONSITE INTERVIEW · Seen Dec 2025
  • Type-Ahead Prefix MatchesONSITE INTERVIEW · Seen Dec 2024
  • Minimum Steps on a Circular Character DialONSITE INTERVIEW · Seen Jan 2024

Similar questions at other companies

  • Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
  • Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
  • Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
  • Roman to IntegerKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Minimum Difference Between Two Clock TimesMicron Technology · PHONE SCREEN
  • Decimal Digits in OrderZoomInfo · PHONE SCREEN
  • Add Two Integers Given as StringsJane Street · PHONE SCREENJane Street interview questions
  • Fizz and Buzz Words From 1 to nDocuSign · PHONE SCREENDocuSign interview questions
  • Integer to String Without Built-insHudson River Trading · PHONE SCREENHudson River Trading interview questions
All Navan interview questionsSee Navan hiring insights
Saved
class Solution {
    public int romanToInteger(String roman) {
        // Write your code here.
    }

}
Checking account…