In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how LeetCode converts Roman numerals to integers. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
one
Topic description
In Roman numerals, the correspondence between letters and numbers is as follows:
I
one
V
five
X
ten
L
fifty
C
one hundred
D
five hundred
M
one thousand
Usually, large numbers are on the left and small numbers are on the right, such as VI means 6, when small numbers are on the left and large numbers are on the right, large numbers subtract decimals, such as IV means 4. The requirement for this topic is to give a Roman numeral to be converted to an integer.
two
Knowledge point
Idea: establish a hash table
Firstly, the hash correspondence table between Roman letters and numbers is established through the dictionary structure, and then the corresponding values are added or subtracted according to the size relationship between the two characters.
Class Solution: def romanToInt (self, s: str)-> int: RomanDict = {'Illustrated self, s: str)-> int: RomanDict = {' I]: if RomanDice [I]
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.