当前位置:网站首页>Map in JS (including leetcode examples)
Map in JS (including leetcode examples)
2022-07-02 05:00:00 【Out of the autistic bird】
Map
JS Provide us with ready-made Map structure , It can be understood as a set of key value pairs
For specific usage, please refer to teacher Ruan Yifeng's article
leetcode Example
It was also used in many places in the section of array map
JS In the array ( contain leetcode Example )< Continuous updating ~>
13. Roman numeral to integer
var romanToInt = function(s) {
let res =0
let map = new Map([
['I',1],
['V',5],
['X',10],
['L',50],
['C',100],
['D',500],
['M',1000],
])
let length = s.length
for(let i=0;i<length;i++){
let value = map.get(s[i])
if(i<length&&value<map.get(s[i+1])){
res = res - map.get(s[i])
}else{
res = res + map.get(s[i])
}
}
return res
};
边栏推荐
- Getting started with pytest -- description of fixture parameters
- 数学知识——快速幂的理解及例题
- Hcip day 17
- 2022 Alibaba global mathematics competition, question 4, huhushengwei (blind box problem, truck problem) solution ideas
- How to recover deleted data in disk
- Lay the foundation for children's programming to become a basic discipline
- Mouse events in JS
- Analyzing the hands-on building tutorial in children's programming
- VMware installation win10 reports an error: operating system not found
- Fasttext text text classification
猜你喜欢

VMware installation win10 reports an error: operating system not found

Ansible installation and use
![Learn AI safety monitoring project from zero [attach detailed code]](/img/a9/cb93f349229e86cbb05ad196ae9553.jpg)
Learn AI safety monitoring project from zero [attach detailed code]

Pytest learning ----- pytest Interface Association framework encapsulation of interface automation testing

Precipitate yourself and stay up late to sort out 100 knowledge points of interface testing professional literacy
![[Yu Yue education] autumn 2021 reference materials of Tongji University](/img/50/5136359b89a5d047fe648637643ad0.jpg)
[Yu Yue education] autumn 2021 reference materials of Tongji University

How to recover deleted data in disk

The underlying principle of go map (storage and capacity expansion)

Leetcode merge sort linked list

Here comes the chicken soup! Keep this quick guide for data analysts
随机推荐
Practical problem solving ability of steam Education
Analyzing the hands-on building tutorial in children's programming
10 minute quick start UI automation ----- puppeter
Mysql database learning
Go Chan's underlying principles
Realize the function of data uploading
Ansible installation and use
Fasttext text text classification
win11安装pytorch-gpu遇到的坑
Tawang food industry insight | current situation, consumption data and trend analysis of domestic infant complementary food market
fastText文本分类
One step implementation of yolox helmet detection (combined with oak intelligent depth camera)
Mapping settings in elk (8) es
Typescript function details
LM09丨费雪逆变换反转网格策略
Vmware安装win10报错:operating system not found
geotrust ov多域名ssl证书一年两千一百元包含几个域名?
Mathematical knowledge -- understanding and examples of fast power
Acelems Expressway microgrid energy efficiency management platform and intelligent lighting solution intelligent lighting tunnel
记录一次Unity 2020.3.31f1的bug