[Leetcode]012. Integer to Roman
public class Solution {
public String intToRoman(int num) {
String M[] = {"", "M", "MM", "MMM"};
String C[] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
String X[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
String I[] = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
return M[ num/1000 ] +
C[ (num%1000) / 100] +
X[(num%100)/10] +
I[num%10];
}
}
[Leetcode]012. Integer to Roman的更多相关文章
- 【JAVA、C++】LeetCode 012 Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
- [LeetCode][Python]Integer to Roman
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/integer ...
- 【leetcode】Integer to Roman
Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within t ...
- 【leetcode】Integer to Roman & Roman to Integer(easy)
Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within t ...
- No.012 Integer to Roman
12. Integer to Roman Total Accepted: 71315 Total Submissions: 176625 Difficulty: Medium Given an int ...
- Leetcode 12——Integer to Roman
12.Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be withi ...
- LeetCode--No.012 Integer to Roman
12. Integer to Roman Total Accepted: 71315 Total Submissions: 176625 Difficulty: Medium Given an int ...
- Leetcode 12. Integer to Roman(打表,水)
12. Integer to Roman Medium Roman numerals are represented by seven different symbols: I, V, X, L, C ...
- 【LeetCode】012. Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
随机推荐
- FFMPEG-AVFilter研究
FFMPEG中的libswscale是做像素转换的,但是对于一些复杂的操作,比如添加水印等,这个库就不行了,这时候就要说一下另外一个AVFilter.AVFilter完全可以替代libswscale的 ...
- ACdream1430SETI(后缀自动机)
问题: Amateur astronomers Tom and Bob try to find radio broadcasts of extraterrestrial civilizations i ...
- tiny4412sdk-1506原生uboot卡死
于16年2月多购买了tiny4412sdk-1506,用友善之臂(以下简称友善)的superboot是可以进入linux,而用三星原始的uboot_tiny4412-20130729则不可以.出现现象 ...
- Maven(6)-POM
to be continued.
- JZOJ 1003【东莞市选2007】拦截导弹——dp
题目:https://jzoj.net/senior/#main/show/1003 只要倒推一下第一次上升的最长和第一次下降的最长就行了.不用n^2logn,枚举了 j 还要用树状数组找值比自己大的 ...
- Boost库之asio io_service以及run、run_one、poll、poll_one区别
一.io_service的作用 io_servie 实现了一个任务队列,这里的任务就是void(void)的函数.Io_servie最常用的两个接口是post和run,post向任务队列中投递任务,r ...
- 机器学习:k-NN算法(也叫k近邻算法)
一.kNN算法基础 # kNN:k-Nearest Neighboors # 多用于解决分裂问题 1)特点: 是机器学习中唯一一个不需要训练过程的算法,可以别认为是没有模型的算法,也可以认为训练数据集 ...
- java流类
总结:new FileInputStream package com.ds; import java.io.*; import com.da.fgbv; public class rter { pub ...
- Nuget:目录
ylbtech-Nuget:目录 1.返回顶部 1. https://www.nuget.org 2. https://docs.microsoft.com/zh-cn/nuget/ 3. https ...
- java web 基础 json 和 javaBean转化
github地址: https://github.com/liufeiSAP/JavaWebStudy 实体类: package com.study.demo.domain; import com.f ...