This is the best solution I’ve seen for this question. Very well explained. Thank you!
@EricProgramming2 жыл бұрын
Glad it was helpful!
@valkon_2 жыл бұрын
Thank you for the solution, it's really important to utilize the data structures. Sadly, this question demands to be solved in place and I honestly hate it. No one will come up with counting zeroes trick on an interview first time seeing the problem, they do not want problem solvers they want master of memorization.
@nwokolobueze72912 жыл бұрын
This makes so much sense to me. Good job Eric.
@frankf53982 жыл бұрын
Best understandable and easiest solution. Big thanks
@EricProgramming2 жыл бұрын
You're welcome!
@akoboyd10992 жыл бұрын
This was the best solution. Surprised as you were only one I saw use this implementation.
@spemovie2 жыл бұрын
But why do we need this solution if the task could be solved in O(1) memory
@edavar6265 Жыл бұрын
I was trying to do something similiar with variables but using a queue is really smart! Thanks a lot. Do you think I can solve it by storing the to-be-shifted elements into an array?
@arif30122 жыл бұрын
Great explanation using Queue ⌨5:27
@EricProgramming2 жыл бұрын
Thanks! 😃
@osamaalsalman68652 жыл бұрын
That's a smart way to solve it! Thanks!
@vishalialahappan90692 ай бұрын
Elegant resolve!
@mingyueliu77796 ай бұрын
That's true that it's kinda hard to bring up 2pointer at interview, I like your solution way better, thanks !
@weiwang47982 жыл бұрын
Wonderful explanation! Thanks, Eric!
@EricProgramming2 жыл бұрын
Very welcome!
@aaronelmquist86075 ай бұрын
Great solution.
@shrirangjoshi65686 ай бұрын
Good solution
@damianwojtowicz52122 жыл бұрын
OO man, this is briliant!!!
@kidztse Жыл бұрын
Smart !!!!
@snowglider4002 жыл бұрын
You shouldn't need to use another data structure for this. just use the same array and shift the last elements out of place.
@lucasgontijo2187 Жыл бұрын
What did u mean? The thing is that the array should be right shifted entirely, not just the last position
@shubhamkumar-gw4vb2 жыл бұрын
nicely explained , could've emphasized a bit more on the coding part though
@EricProgramming2 жыл бұрын
In the future I will
@aabhishek49112 жыл бұрын
The code is pretty easy after the explanation
@UnfinishedYara Жыл бұрын
Dude how is this marked easy??
@krityaan6 ай бұрын
Ignore the constraints xD
@dk--219 ай бұрын
Good solution but this violates the constraints of the problem to solve in-place.
@Sranju238 ай бұрын
how? He didnt create new array and updated existing