From today, I will write my code post in English.
There may be grammatical or spelling errors.
This is the link to problem 13.
Explain the problem easily, just change the roman number to an integer.
By using I=1, V=5, X=10, L=50, C=100, D=500, M=1000
But there is one thing to care about.
There can't be four consecutive identical roman numerals.
So they express 4 written as IV.
If a small number is placed before a large number, then subtract a small number from a large number.
Below is the solution I wrote.
Add roman to the result when it is larger than the next roman number.
Subtract roman from the result when it is smaller than the next roman number.
The time efficiency of this code is in the top 11.60%, and the space efficiency is in the top 69.68%.
'Code > LeetCode' 카테고리의 다른 글
[LeetCode] 35. Search Insert Position (Easy/Python) (0) | 2022.09.03 |
---|---|
[LeetCode] 20.Valid Parentheses (Easy/Python) (0) | 2022.09.02 |
[LeetCode] 9.Palindrome Number (Easy/Python3) (0) | 2022.08.30 |
[LeetCode] 1.Two Sum (Easy/Python3) (1) | 2022.08.29 |
[LeetCode] LeetHub를 이용한 GitHub 자동 업로드 (0) | 2022.08.27 |