13. Roman to Integer
来源:互联网 发布:java项目书籍 编辑:程序博客网 时间:2024/06/17 09:13
class Solution {public: int romanToInt(string s) { int res=0; unordered_map<char,int> m{{'I',1},{'V',5},{'X',10},{'L',50},{'C',100},{'D',500},{'M',1000}}; for(int i=0;i<s.size();i++){ int val=m[s[i]]; if(i==s.size()-1||val>=m[s[i+1]]) res+=val; else res-=val; } return res; }};
阅读全文
0 0
- 13. Roman to Integer
- 13.Roman to Integer
- 13. Roman to Integer
- 13.Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- 13. Roman to Integer
- pdf首页缩略图
- java 面试
- Qt资料大全
- java freemark导出word (模板、单张图片、多张图片源码)
- Masonry使用及注意
- 13. Roman to Integer
- eclipse4.5.2版本安装springsource-tool-suite插件成功之后找不到spring的处理办法
- android实现图片与背景的圆角
- c++string类
- Tomcat 部署 HTTPS 证书
- 设计模式之工厂方法模式(Factory Method)
- iOS Xcode中怎么找到Archive出的项目
- sql server windows 登录出现了18456错误
- 连接VPN后无法连接外网QQ可以上去但打不开网页终极解决方案实测好用