题目:

        Given a roman numeral, convert it to an integer.

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

    给定一个罗马数字,将其转换为整数,输入保证在从1到3999之间。


思路:

   查看罗马数字表,I对应1,V对应5,X对应10,L对应50,C对应100,D对应500,M对应1000,罗马数计算规则为,相同的数字连写,表示的数等于这些数相加,但连续的数重复不能超过三次,比如说III = 3;当小的数在打的右边,所表示的数等于这些数字相加,VII = 7;当小的数在大的数左边(除I、X、C),所表示的数等于大的数减去小的数,IV = 4。

LeetCode编程练习 - Roman to Integer学习心得

相关文章:

  • 2021-05-22
  • 2022-02-12
  • 2021-11-24
  • 2021-12-28
  • 2021-11-22
  • 2022-03-01
  • 2022-02-19
  • 2021-12-29
猜你喜欢
  • 2021-04-06
  • 2021-12-31
  • 2022-02-15
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案