C 100
D 500
M 1000
For example, 2
is written as II
in Roman numeral, just two one’s added together. 12
is written as XII
, which is simply X + II
. The number 27 is written as XXVII
, which is XX + V + II
.
Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII
. Instead, the number four is written as IV
. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX
. There are six instances where subtraction is used:
-
I
can be placed beforeV
(5) andX
(10) to make 4 and 9. -
X
can be placed beforeL
(50) andC
(100) to make 40 and 90. -
C
can be placed beforeD
(500) andM
(1000) to make 400 and 900.
Given an integer, convert it to a roman numeral.
Example 1:
Input: num = 3
Output: “III”
Example 2:
Input: num = 4
Output: “IV”
Example 3:
Input: num = 9
Output: “IX”
Example 4:
Input: num = 58
Output: “LVIII”
Explanation: L = 50, V = 5, III = 3.
Example 5:
Input: num = 1994
Output: “MCMXCIV”
Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.
Constraints:
- 1 <= num <= 3999
略
public class IntegerToRoman {
// 方法一:我写的
public String intToRoman1(int num) {
if (num < 1 || num > 3999)
throw new IllegalArgumentException(String.valueOf(num));
StringBuilder sb = new StringBuilder();
int digit = 0;
while (num > 0) {
int n1 = num % 10;
if (n1 != 0) {
int n2 = n1 * (int) Math.pow(10, digit);
sb.insert(0, map(n2));
}
digit++;
num /= 10;
}
return sb.toString();
}
private String map(int num) {
if (0 < num && num <= 3)
return repeat(“I”, num);
if (num == 4)
return “IV”;
if (5 <= num && num <= 8)
return “V” + repeat(“I”, num - 5);
if (num == 9)
return “IX”;
if (10 <= num && num <= 30)
return repeat(“X”, num / 10);
if (num == 40)
return “XL”;
if (50 <= num && num <= 80)
return “L” + repeat(“X”, num / 10 - 5);
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V获取:vip1024b (备注Java)
最后
即使是面试跳槽,那也是一个学习的过程。只有全面的复习,才能让我们更好的充实自己,武装自己,为自己的面试之路不再坎坷!今天就给大家分享一个Github上全面的Java面试题大全,就是这份面试大全助我拿下大厂Offer,月薪提至30K!
我也是第一时间分享出来给大家,希望可以帮助大家都能去往自己心仪的大厂!为金三银四做准备!
一共有20个知识点专题,分别是:
Dubbo面试专题
JVM面试专题
Java并发面试专题
Kafka面试专题
MongDB面试专题
MyBatis面试专题
MySQL面试专题
Netty面试专题
RabbitMQ面试专题
Redis面试专题
Spring Cloud面试专题
SpringBoot面试专题
zookeeper面试专题
常见面试算法题汇总专题
计算机网络基础专题
设计模式专题
pringBoot面试专题**
[外链图片转存中…(img-avcqCfKI-1711704902721)]
zookeeper面试专题
[外链图片转存中…(img-xfe6QrHd-1711704902721)]
常见面试算法题汇总专题
[外链图片转存中…(img-cPFuHmFm-1711704902722)]
计算机网络基础专题
[外链图片转存中…(img-6oMRWYwu-1711704902722)]
设计模式专题
[外链图片转存中…(img-JxbThN1a-1711704902722)]