leetcode12
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 / ] + C[(num % ) / ] + X[(num % ) / ] + I[num % ];
}
}
https://leetcode.com/problems/integer-to-roman/#/description
leetcode12的更多相关文章
- LeetCode12 Integer to Roman
题意: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from ...
- [Swift]LeetCode12. 整数转罗马数字 | Integer to Roman
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 ...
- LeetCode12.整数转罗马数字
给定一个整数,将其转为罗马数字.输入确保在 1 到 3999 的范围内. 示例 1: 输入: 3 输出: "III" 示例 2: 输入: 4 输出: "IV" ...
- LeetCode12.整数转罗马数字 JavaScript
罗马数字包含以下七种字符: I, V, X, L,C,D 和 M. 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如, 罗马数字 2 写做 II ,即为两个并 ...
- leetcode-12双周赛-1246-删除回文子数组
题目描述: 方法:区间dp O(N^3) class Solution: def minimumMoves(self, A: List[int]) -> int: N = len(A) dp = ...
- leetcode-12双周赛-1245-树的直径
题目描述: 方法一:深度优先: class Solution: def treeDiameter(self, edges: List[List[int]]) -> int: adjacency ...
- leetcode-12双周赛-1243-数组变换
题目描述: 自己的提交: class Solution: def transformArray(self, arr: List[int]) -> List[int]: if len(arr) & ...
- leetcode-12双周赛-1244-力扣排行榜
题目描述: class Leaderboard: def __init__(self): self.map = collections.Counter() def addScore(self, pla ...
- leetcode-12周双周赛-5090-抛掷硬币
题目描述: 二维dp: class Solution: def probabilityOfHeads(self, prob: List[float], target: int) -> float ...
随机推荐
- 29-THREE.JS 根据公式画形状
<!DOCTYPE html> <html> <head> <title></title> <script src="htt ...
- poj2446
题解: 二分图匹配 看看是否能达到目标 代码: #include<cstdio> #include<cstring> #include<algorithm> #in ...
- WEB-INFO里面的jsp文件不能通过href 访问,而只能通过 servlet访问
href="<%=basePath %>index.jsp"> 这种确实 可以在jsp页面跳转至另一个页面,只不过要放在WEB-INFO外面,也就是项目根目录下面 ...
- Ubuntu語言支持爲灰色修復方法
Ubuntu語言支持爲灰色修復方法 在Ubuntu12.04中,在下不知爲何將 語言支持 中 應用到整個系統 和 添加語言 這2個按弄成了灰色,導致ibus不能輸入中文,現在唔將修復方法公告天下: 1 ...
- 利用selenium webdriver点击alert提示框
在进行元素定位时常常遇到这样的alert框: 那么该如何定位并点击确定或取消按钮呢?stackoverflow上找到了这个问题的答案. OK, Show you the code: driver.fi ...
- EasyDSS流媒体服务器出现no compatible source was found for this media问题的解决
在EasyDSS流媒体服务器的客户反馈中,我们遇到这样一个现象,在chrome中经常会出现RTMP/HLS流无法播放的问题: 这个问题复现的几率比较低,因为chrome禁止了flash的加载,这也从另 ...
- js实现checkbox组 全选和取消全选
做后台管理程序时,用到一个checkbox组的全选和取消全选的功能, 主要是逻辑上的坑,理清后大概是: 1.全选点击后,小弟1~4都要选上,点击取消,小弟们也要取消 2.只要有一个小弟取消时,全选要取 ...
- make: *** No rule to make target `out/target/common/obj/APPS/framework-res_intermediates/src/R.stamp'
/********************************************************************************** * make: *** No r ...
- echarts.js:1136 Uncaught Error: Initialize failed: invalid dom.
一:错误描述:echarts.js:1136 Uncaught Error: Initialize failed: invalid dom. 二:错误原因:echarts在用json数据请求时未调用 ...
- Elasticsearch.net项目
Elasticsearch.net项目实战 https://www.cnblogs.com/lucky_hu/p/9746736.html elasticsearch.net项目实战 @智客幸达 目录 ...