Function to find the maximum neighbor within the distance of less than equal to K
static int [ ] [ ] getMaxNeighbour ( int [ ] [ ] A , int K ) { int [ ] [ ] ans = new int [ A . length ] [ A [ 0 ] . length ] ; copyMatrix ( ans , A ) ;