Solving "Roman to Integer" from LeetCode ( Easy ) - Problem solving in JS

Sdílet
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

Komentáře • 20

  • @tatianabowman
    @tatianabowman Před rokem

    omg, this solution is great! Really helped me understand the problem!

  • @georgeyxu
    @georgeyxu Před rokem +1

    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 :)

  • @3MILFOR3VER
    @3MILFOR3VER Před rokem

    awesome solution

  • @neeraj1954
    @neeraj1954 Před 6 měsíci

    its amazing..

  • @isakawilliam
    @isakawilliam Před rokem +1

    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. 🔥🔥

  • @anilKUMAR-wr2pi
    @anilKUMAR-wr2pi Před 2 lety

    Thanks man🌹

    • @Rowadz
      @Rowadz  Před 2 lety

      You're welcome :)

  • @shahriarbhuyian850
    @shahriarbhuyian850 Před rokem

    GREAT

  • @newtypetommy
    @newtypetommy Před rokem

    I did this without arrow functions and got slower with more memory usage. Is this normal? does using arrow functions use less memory?

    • @Rowadz
      @Rowadz  Před rokem +1

      Not sure why it's slower, but for memory it could be because arrow functions don't have "arguments" or "this" or "new.target"

    • @Rowadz
      @Rowadz  Před rokem +1

      Read more here:
      developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
      I hope this helps

  • @TekkenRoom
    @TekkenRoom Před 2 lety +1

    can you please explain this part " res -=map[num] & res+=map[num] "

    • @synaxreader9326
      @synaxreader9326 Před 2 lety +8

      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'

    • @TekkenRoom
      @TekkenRoom Před 2 lety +1

      @@synaxreader9326 much thanks to you sir 🙏

    • @kwandamadela7707
      @kwandamadela7707 Před rokem +1

      @@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')??

    • @arshadchowdhury5939
      @arshadchowdhury5939 Před rokem +1

      ​@@kwandamadela7707 num is not a number here, it's the roman number, type of which is a string actually.

    • @kwandamadela7707
      @kwandamadela7707 Před rokem

      @@arshadchowdhury5939 Thanks a lot mate 🙌

  • @abhishektripathi3536
    @abhishektripathi3536 Před 6 měsíci

    sequence =
    "aaabaaaabaaabaaaabaaaabaaaabaaaaba"
    word =
    "aaaba"

  • @chrismetsios4005
    @chrismetsios4005 Před 2 lety +1

    Yeah don’t think you need .split but nice

    • @Spacey.
      @Spacey. Před 2 lety +6

      You need .split('') to convert the string to a character array