PRODUCT OF TWO RUN-LENGTH ENCODED ARRAYS | PYTHON | LEETCODE # 1868

Sdílet
Vložit
  • čas přidán 9. 07. 2024
  • In this video we are solving a popular Facebook and Twitter interview question: Product of Two Run-Length Encoded Arrays (Leetcode # 1868).
    This is a pretty straightforward two pointer based solution though it may take seeing the solution once to be able to wrap your head around why it works and how this is truly the most optimal way to solve the question.
  • Věda a technologie

Komentáře • 10

  • @SriHarshaBolisetti
    @SriHarshaBolisetti Před 2 lety

    Perfect explanation :)

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

    Nice explanation.

  • @92AkshaySharma
    @92AkshaySharma Před 7 měsíci

    man good job explaining this one.

  • @mohammadkareem1187
    @mohammadkareem1187 Před 2 lety

    Thanks for the clear explanation and great video. My only comment is to use a pen rather than a mouse when you write. Good luck

    • @crackfaang
      @crackfaang  Před rokem +1

      Totally agree with you but the channel is still too small to warrant buying an iPad + magic pencil just to write a little bit cleaner. I see the video analytics and most people just jump to the code anyway so the cost/benefit of investing in that right now is not skewed in the right direction. I probably will eventually because using a mouse sucks 😂

    • @mohammadkareem1187
      @mohammadkareem1187 Před rokem

      @@crackfaang if I pass my upcoming interview, I will buy you an iPad + magic pencil ;)

  • @lcgrind
    @lcgrind Před 4 měsíci

    Ty! I had the same intuition in terms of optimizating the solution, but couldn't translate it into code. How would you update your solution if modifying the input is not allowed?

    • @lcgrind
      @lcgrind Před 4 měsíci

      Answering my own Q if anyone else wonders; we can create two additional variables to keep track of the frequencies; init these to the frequency for the first val/freq element of the encoded array (repsectveily); in each iteration, get the min frequency and substract these from the two variables. If their value is 0, advance their respective pointer, and retrieve the frequency only if their pointer is less than their respective encoded size.
      I hope this helps others! and GL with your prep!

  • @abhi23pawar
    @abhi23pawar Před 4 měsíci

    What about carry? say 9x9 = 81