Source: making power button (LeetCode) | | to brush the topic card for stars ✨ | give a ❤ ️ attention, ❤ ️ thumb up, ❤ ️ encourages the author
[Opened] Task 1: Brush the question punch card * 10
Nezha’s life creed: If you like what you learn, there will be strong motivation to support it.
Learn programming every day, so that you can get a step away from your dream. Thank you for not living up to every programmer who loves programming. No matter how strange the knowledge point is, work with me to calm down the wandering heart and keep going. Welcome to follow me vx:xiaoda0423, welcome to like, favorites and comments
Time: March 1 ~ March 13
- Force buckle (LeetCode)- Sum of two numbers, valid parentheses, sum of two numbers | brush questions punch card – March 1
- LeetCode – Merges two ordered lists, removes duplicates in sorted arrays,JavaScript Notes | Flash cards – March 2
- Force Button (LeetCode)- Maximum suborder sum,JavaScript Data Structures and Algorithms (Arrays) | Brush questions punched -3 March
- Say something about CSS | Tech Review – March 4
- Force Buckle (LeetCode)- Stack, parenthesis generation | brush questions punch card – 5 March
- It wasn’t that hard! Vue mall development | technical review – on March 6
- Force buckle (LeetCode)- Plus one, queue | brush questions punch – 7 March
- JavaScript data structure of the chain table | technical review – March 8
- JavaScript Data Structures – Collections | Technical Review – March 9
- LeetCode – Merge two ordered arrays, dictionary, hash table | swipe card – March 10
- Force Buckle (LeetCode)- Symmetric binary Tree, Tree | Brush title punch card – March 11
- Force buckle (LeetCode)-104. Maximum depth of binary tree, figure | brush problem clocking – March 12
preface
If this article is helpful to you, give ❤️ a follow, ❤️ like, ❤️ encourage the author, accept the challenge? Article public account launch, concern programmer Doraemon first time access to the latest article
❤ ️ cartridge ❤ ️ ~
Stack, queue, linked list, set, dictionary and hash table, tree, graph
13. Convert Roman numerals to whole numbers
1. Title Description
Roman numerals contain the following seven characters: I, V, X, L, C, D and M.
Second, train of thought analysis
- Roman numerals are made up of
I,V,X,L,C,D,M
A; - When a small value is to the left of a large value, the value decreases, e.g
IV=5-1=4
- When the small value is to the right of the large value, the small value is added, as in
VI=5+1=6
- The rvalue is always positive, so the last digit must be positive
Putting a small value to the left of a large value is subtraction, otherwise addition.
- All combinatorial possibilities are first listed and added to the hash table
- And then I iterate over the string, because there are only two combinations, one is
1
Two characters, one is2
A character, where2
A character takes precedence over1
A character - Determine if the combination of two characters exists in the hash table, and then extract the value and add it to the result
ans
Medium, and move back2
A character. If it does not exist, the current is judged1
If the character exists, the value is extracted and added to the resultans
Medium, and move back1
A character - The result is returned at the end of traversal
ans
Answer code
var romanToInt = function(s) { let map = { I: 1, IV: 4, V: 5, IX: 9, X: 10, XL: 40, L: 50, XC: 90, C: 100, CD: 400, D: 500, CM: 900, M: 1000 } let ans = 0; for(let i=0; i<s.length;) {if (I + 1 < s.l ength && map [s.s ubstring (I, I + 2)]) {/ / a group ans + 2 = map [s.s ubstring (I, I + 2)]; i += 2; }else{// single ans += map[s.substring(I, I +1)]; i++; } } return ans; };Copy the code
Four,
- Roman numerals to whole numbers
Go back to my previous articles and you may get more!
- A qualified junior front-end engineer needs to master module notes
- Vue.js pen test questions Solve common business problems
- [Primary] Personally share notes of Vue front-end development tutorial
- A long summary of JavaScript to consolidate the front end foundation
- ES6 comprehensive summary
- Dada front-end personal Web share 92 JavaScript interview questions with additional answers
- [Illustrated, like collection oh!] Re-study to reinforce your Vuejs knowledge
- 【 Mind Mapping 】 Front-end development – consolidate your JavaScript knowledge
- 14 – even liver 7 nights, summed up the computer network knowledge point! (66 items in total)
- This was my first JavaScript primer
- LocalStorage and sessionStorage localStorage
- Drag and drop in HTML5
- Challenge the front-end HTTP/ECMAScript
- Must learn must learn – Audio and video
- 170 Interview questions + answer Learn to organize (conscience making)
- Front-end HTML5 interviewers and candidates ask and answer questions
- Ne Zha is sweeping the sea
- Tencent location service development applications
- [Advanced] The interviewer asked me how Chrome renders (6000 words)
- The interviewer started by asking me about Chrome’s underlying principles and HTTP protocol (swastika)
- Staying up late summed up the “HTML5 Canvas”
- This /call/apply/bind
- The HTTP/HTTPS/HTTP2 / DNS/TCP/classic problem
- Execute context/scope chain/closure/first-class citizen
- Web page creation basics
- Learn the summary of HTML5 finger front-end (suggested collection, illustrated)
❤️ follow + like + favorites + comments + forward ❤️, original is not easy, encourage the author to create better articles
Likes, favorites and comments
I’m Jeskson, thanks for your talent: likes, favorites and comments, and we’ll see you next time! ☞ Thank you for learning with me.
See you next time!
This article is constantly updated. You can search “Programmer Doraemon” on wechat to read it for the first time, and reply [information] there are materials of first-line big factories prepared by me, which have been included in this article www.dadaqianduan.cn/#/
Star: github.com/webVueBlog/…
This article is participating in the “Nuggets 2021 Spring Recruitment Campaign”, click to see the details of the campaign