其他分享
首页 > 其他分享> > 13. Roman to Integer

13. Roman to Integer

作者:互联网

  1. I can be placed before V (5) and X (10) to make 4 and 9.
  2. X can be placed before L (50) and C (100) to make 40 and 90.
  3. C can be placed before D (500) and M (1000) to make 400 and 900.
  4. Given a roman numeral, convert it to an integer.

Example 1:

Input: s = "III"
Output: 3

Example 2:

Input: s = "IV"
Output: 4

Example 3:

Input: s = "IX"
Output: 9

Example 4:

Input: s = "LVIII"
Output: 58
Explanation: L = 50, V= 5, III = 3.

Example 5:

Input: s = "MCMXCIV"
Output: 1994
Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.

Constraints:

public class Solution {
    public int RomanToInt(string s) {
        
    }
}

标签:13,Output,written,Roman,Input,Integer,Example,numeral,before
来源: https://www.cnblogs.com/MrFlySand/p/15390300.html