leetcode 12 Integer to Roman
lc12 Integer to Roman
因为题目输入只有1~3999,只需要将所有情况列出即可
1 class Solution { 2 public String intToRoman(int num) { 3 String[] symbol = {"M", "CM", "D","CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"}; 4 int[] value = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; 5 StringBuilder sb = new StringBuilder(); 6 for(int i=0; i<13; i++){ 7 while(num >= value[i]){ 8 sb.append(symbol[i]); 9 num -= value[i]; 10 } 11 } 12 13 return sb.toString(); 14 } 15 }
转载于:https://www.cnblogs.com/hwd9654/p/10971857.html
leetcode 12 Integer to Roman相关推荐
- LeetCode 12. Integer to Roman
题目: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from ...
- LeetCode 12 Integer to Roman (整数转罗马数字)
题目链接: https://leetcode.com/problems/integer-to-roman/?tab=Description String M[] = {"", &q ...
- 【LeetCode】12. Integer to Roman 整型数转罗马数
题目: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from ...
- 【leetcode】Integer to Roman
最近使用开发的过程中出现了一个小问题,顺便记录一下原因和方法-- Question : Given an integer, convert it to a roman numeral. Input ...
- leetcode 12 ,13 Integer to Roman amp;amp;Roman to Integer 罗马与阿拉伯数组转换
12 Integer to Roman 13 Roman to Integer 有可能不注意的结果: class Solution {public:/*1.相同的数字连写,所表示的数等于这些数字相加得 ...
- LeetCode算法入门- Roman to Integer Integer to Roman -day8
LeetCode算法入门- Roman to Integer -day8 Roman to Integer: 题目描述: Roman numerals are represented by seven ...
- Integer to Roman 问题
Integer to Roman 问题 leetcode java 1.问题描述 Given an integer, convert it to a roman numeral.Input is gu ...
- lintcode :Integer to Roman 整数转罗马数字
题目 整数转罗马数字 给定一个整数,将其转换成罗马数字. 返回的结果要求在1-3999的范围内. 样例 4 -> IV 12 -> XII 21 -> XXI 99 -> XC ...
- Roman to Integer/Integer to Roman
1 Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within ...
- [LeetCode]Integer to Roman
题目描述:(链接) Given an integer, convert it to a roman numeral. Input is guaranteed to be within the rang ...
最新文章
- 20年研发管理经验谈(五)
- TF实现多minibatch梯度累加及反向更新
- Spring交易可见性
- 【渝粤题库】国家开放大学2021春3907安全原理题目
- 前端学习(604):编程语言
- 三种嵌入式操作系统的分析与比析
- pt100温度传感器c语言,pt100测温程序-LCD1602
- iOS开发---- 开发错误汇总及解决方法
- python考勤管理系统_python基础教程:face++与python实现人脸识别签到(考勤)功能...
- AIX系统修改用户密码依然无法登录
- 微星小飞机界面翻译_6 款实用小程序良心推荐,每一款都好用
- Synchronized原理(轻量级锁篇)
- Word 分节符插入与删除方法
- the disk drive for uuid=XXXX ( /media/sda1) is not reday yet or not present
- Vue SPA项目SEO优化之预渲染Prerender-spa-plugin
- filebeat+redis+logstash+elasticsearch filebeat+kafka+zookeeper+logstash+elasticsearch
- 优秀课程案例:使用Scratch制作汉诺塔的演示
- PSInSAR技术建筑物/构筑物高度信息提取
- 在Windows下架设FTP服务器
- 北风网web前端开发培训课程 web前端开发实例视频教程下载
热门文章
- 数据结构和算法——八种常用的排序算法------归并排序
- 计算机秘密程序 听课反思,《编制计算机程序解决问题》的教学反思
- html a 的写法,HTML超链接a标记CSS样式写法示例
- mysql里面手动关闭_MySQL 启动与关闭(手动与自动)
- java基础总结06-常用api类-BigDecimal-精确计算
- SQL中truncate 、delete与drop区别 (Rollback Segment)
- podman 在 windows 安装
- git SSH 公钥拉取代码(使用及配置)
- 阶段3 3.SpringMVC·_01.SpringMVC概述及入门案例_05.入门程序之入门代码编写
- 有目标就有动力!有目标就有意义!