当前位置:网站首页>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
};
边栏推荐
- 数学知识(欧拉函数)
- Application of intelligent robot in agricultural ecology
- Go Chan's underlying principles
- Idea autoguide package and autodelete package Settings
- 10 minute quick start UI automation ----- puppeter
- GeoTrust ov multi domain SSL certificate is 2100 yuan a year. How many domain names does it contain?
- 解决:代理抛出异常错误
- Its appearance makes competitors tremble. Interpretation of Sony vision-s 02 products
- Oracle stored procedure and job task setting
- Promise all()
猜你喜欢

How to write a client-side technical solution

Summary of main account information of zhengdaliu 4

Analyze the space occupied by the table according to segments, clusters and pages

Steam教育的实际问题解决能力

Analyzing the hands-on building tutorial in children's programming

Unity particle Foundation

洛谷入门3【循环结构】题单题解

Video multiple effects production, fade in effect and border background are added at the same time

关于Steam 教育的知识整理

Orthogonal test method and function diagram method for test case design
随机推荐
Vmware安装win10报错:operating system not found
UNET deployment based on deepstream
Summary of main account information of zhengdaliu 4
面试会问的 Promise.all()
案例分享|智慧化的西部机场
oracle 存储过程与job任务设置
Mapping settings in elk (8) es
Future trend of automated testing ----- self healing technology
C# 图片显示占用问题
10 minute quick start UI automation ----- puppeter
Beginner crawler - biqu Pavilion crawler
One step implementation of yolox helmet detection (combined with oak intelligent depth camera)
奠定少儿编程成为基础学科的原理
How to configure PostgreSQL 12.9 to allow remote connections
Let genuine SMS pressure measurement open source code
js面试收藏试题1
The underlying principle of go map (storage and capacity expansion)
C # picture display occupancy problem
Ansible installation and use
Ruby replaces gem Alibaba image