Solving "Roman to Integer" from LeetCode ( Easy ) - Problem solving in JS
Vložit
- čas přidán 12. 03. 2020
- Buy me a coffee if this is useful 😀
www.buymeacoffee.com/rowadz
I'm solving this problem in JS
leetcode.com/problems/roman-t...
* It's just a way for me to keep solving questions... *
My Profile :
leetcode.com/rowadwo/ - Věda a technologie
omg, this solution is great! Really helped me understand the problem!
Awesome solution ! I found out that map.I and map['I'] have the same value, which is 1. Very amazing, and I learned a lot. Thank U :)
awesome solution
its amazing..
i did it differently and got 52mb of memory usage and just faster than 5%😂😂 I feel dumb af, but this is a silky solution. 🔥🔥
Thanks man🌹
You're welcome :)
GREAT
I did this without arrow functions and got slower with more memory usage. Is this normal? does using arrow functions use less memory?
Not sure why it's slower, but for memory it could be because arrow functions don't have "arguments" or "this" or "new.target"
Read more here:
developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
I hope this helps
can you please explain this part " res -=map[num] & res+=map[num] "
Here is the explaination of " res -=map[num] & res+=map[num] ". The reason is, res is initialized to 0. Using "IV" as an example. Since '1'
@@synaxreader9326 much thanks to you sir 🙏
@@synaxreader9326 Hi, I'm new to JS can you please explain what is going on from forEach() and onwards 🙏? Why is 'num' a number and not a property (e.g: 'V:5')??
@@kwandamadela7707 num is not a number here, it's the roman number, type of which is a string actually.
@@arshadchowdhury5939 Thanks a lot mate 🙌
sequence =
"aaabaaaabaaabaaaabaaaabaaaabaaaaba"
word =
"aaaba"
Yeah don’t think you need .split but nice
You need .split('') to convert the string to a character array