I think the Time complexity and space complexity is actually: Max(N,M)
@mohammadkareem11872 жыл бұрын
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
@crackfaang2 жыл бұрын
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 😂
@mohammadkareem11872 жыл бұрын
@@crackfaang if I pass my upcoming interview, I will buy you an iPad + magic pencil ;)
@92AkshaySharma Жыл бұрын
man good job explaining this one.
@SriHarshaBolisetti2 жыл бұрын
Perfect explanation :)
@lcgrind9 ай бұрын
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?
@lcgrind9 ай бұрын
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!