Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
It's more intuitive for me to keep track of the count of 0s instead. The conditi...

SeungJin Kim

Feb 27, 2022

It's more intuitive for me to keep track of the count of 0s instead. The condition then will be 'if zero count > k:'

4

0

Comments
Comments
R
Richard Yuan3 years ago

I agree and that's how I solved it as well. However, I think they wrote the solution this way so it is similar to the previous problem. So by comparing the elements to be replaced with k in both problems, it would hopefully be easier to remember.

On this page