Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6a4b505

Browse files
integer to roman
1 parent2c46b7a commit6a4b505

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

‎MEDIUM/src/medium/IntegertoRoman.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
packagemedium;
2+
3+
publicclassIntegertoRoman {
4+
//looked at this post: https://discuss.leetcode.com/topic/12384/simple-solution
5+
publicStringintToRoman(intnum) {
6+
StringM[] = {"","M","MM","MMM"};
7+
StringC[] = {"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"};
8+
StringX[] = {"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"};
9+
StringI[] = {"","I","II","III","IV","V","VI","VII","VIII","IX"};
10+
returnM[num/1000] +C[(num%1000)/100] +X[(num%100)/10] +I[num%10];
11+
}
12+
13+
}

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
|17|[Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/)|[Solution](../../blob/master/MEDIUM/src/medium/LetterCombinationsofaPhoneNumber.java)|O(n*4^n)|O(n)|Medium|Backtracking
125125
|15|[3Sum](https://leetcode.com/problems/3sum/)|[Solution](../../blob/master/MEDIUM/src/medium/_3Sum.java)|O(n^2)|O(1)|Medium|Two Pointers
126126
|14|[Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix/)|[Solution](../../blob/master/EASY/src/easy/LongestCommonPrefix.java)| O(n*min(wordLength in this array)) | O(1) | Easy
127+
|12|[Integer to Roman](https://leetcode.com/problems/integer-to-roman/)|[Solution](../../blob/master/MEDIUM/src/medium/IntegertoRoman.java)|O(1)|O(1)|Medium|
127128
|10|[Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching/)|[Solution](../../blob/master/HARD/src/hard/RegularExpressionMatching.java)|O(m*n)|O(m*n)|Hard|DP
128129
|9|[Palindrome Number](https://leetcode.com/problems/palindrome-number/)|[Solution](../../blob/master/EASY/src/easy/PalindromeNumber.java)| O(logn)/(n) | O(1) | Easy
129130
|8|[String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/)|[Solution](../../blob/master/EASY/src/easy/StringToInteger.java)| O(n) | O(1) | Easy

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp