loading

Integer to Roman — Step-by-Step Visualization

mediumLeetCode #12Hash TableMathString

Given an integer, convert it to a roman numeral.

Algorithm Pattern

Greedy

Key Idea

Always subtract the largest Roman value possible, greedy from top to bottom.

Step-by-Step Approach

  1. For each value in descending order
  2. While num >= value, append symbol, subtract value

Related Problems