Solution mentioned is wrong in editorial


#1

they are only considering the elements with required condition only on axes x axes and y axes , but there are many points between quadrants also that satisfy the condition , the problem solution is wrong in editorials and solution discussions ,
interviewbit please suggest better solution.


#2

I guess the mentioned solution will cover diagonal points too. First diagonal point needs to be considered if Manhattan distance of 2 is used. So during k = 1 computation, the diagonal point will come to horizontal or vertical adjacent position(if it is bigger), and during k = 2 computation we will consider it automatically.
eg:
{{2,4},{5,1}}:
k=1 => {{5,4},{5,5}}
k=2 =>{{5,5},{5,5}}

The position (0, 1) is ultimately filled by value at its diagonal i.e. (1,0)

I hope it helps!