umdreamer / leetcodeproblems

Solutions for LeetCode OJ
3 stars 9 forks source link

2023.5.6 Problem: 13. Roman to Integer #6

Closed umdreamer closed 1 year ago

umdreamer commented 1 year ago
  1. Roman to Integer Problem Link

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

Symbol       Value
I             1
V             5
X             10
L             50
C             100
D             500
M             1000

For example, 2 is written as II in Roman numeral, just two ones 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:

Example 1:

Input: s = "III"
Output: 3
Explanation: III = 3.

Example 2:

Input: s = "LVIII"
Output: 58
Explanation: L = 50, V= 5, III = 3.

Example 3:

Input: s = "MCMXCIV"
Output: 1994
Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.

Constraints:

zxm-1235 commented 1 year ago

image

bedauern commented 1 year ago
Snipaste_2023-05-06_17-09-18
mafanjia commented 1 year ago

截屏3

ZWJ2212061008 commented 1 year ago

image

foxbou commented 1 year ago

Z97N @UDCLP$)IUL U7U{}N

Lggg1234 commented 1 year ago

屏幕截图 2023-05-06 185451

xkqwww commented 1 year ago

无标题1

liuhuanyu6 commented 1 year ago

image

123lrb commented 1 year ago

F6I)P~KAYJG8VIPT@K4)893

liu-si-han commented 1 year ago
image
htywan commented 1 year ago

3

PinkyLame commented 1 year ago

3

686xiaozhang commented 1 year ago

QQ截图20230506190913

tangyexi commented 1 year ago
屏幕截图 2023-05-06 191421
sjh397 commented 1 year ago

image

zyhzxy99 commented 1 year ago

FRVQZ)HM4X%HVNW{W R 3

huangyumei1 commented 1 year ago

QQ图片20230506194054

zhjingyan commented 1 year ago

image

cuixiao02 commented 1 year ago
截屏2023-05-06 19 51 25
naqianqpg commented 1 year ago

@N2WK}OCT(@6X$H WU5UPEM

daowuwu commented 1 year ago

V08NAZ{BSU_9UG6Q2T}KF2U

wangshiqi7 commented 1 year ago
截屏2023-05-06 20 01 23
12baoxingyu-6 commented 1 year ago

image

xiaolu2002 commented 1 year ago

image

promisewith7 commented 1 year ago

image

qby962464 commented 1 year ago

image

1125766961 commented 1 year ago

image

syr2212061031 commented 1 year ago

K$DWN{YDD4 MS67`)3MDAGY

FXL1006 commented 1 year ago

image

gusuning commented 1 year ago
屏幕截图 2023-05-06 214246
zangfushuo commented 1 year ago
截屏2023-05-06 21 57 04
24zlx commented 1 year ago

联想截图_20230506220901

yeyuxq commented 1 year ago

image

shylieisme commented 1 year ago

{V8)P003EP2CE{7)SM5QZVG