@StefanPochmann

Thanks for the explanation. It makes sense. It also explains why modified solution above works despite overlap in the range.

With solution above, there will be overlap for range 3n+1...4n-2.

And still it is unaffected by the overlap due to following reasons:

Counts in the overlap range can only go up to n-1.
Cells of our interest 3n-1 (antidiagonal) and 4n (diagonal) lie outside of this range.