leetcode [#13] | GCidea's blog
目录1. 题目2. 解决方案3. 注意事项
题目Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
解决方案12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849public class Solution { public int romanToInt(String s) { int len = s.length(); int result = 0; if(s == null || len == 0) return 0; for(int i = 0; i < len; i++){ if(s.charAt(i) == 'M'){ result += 1000; } ...阅读全文
题目Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
解决方案12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849public class Solution { public int romanToInt(String s) { int len = s.length(); int result = 0; if(s == null || len == 0) return 0; for(int i = 0; i < len; i++){ if(s.charAt(i) == 'M'){ result += 1000; } ...阅读全文