Given an array of n * n , give an O(n) algorithm to find out pair of indices i and j such that A[i][j] < A[i-1][j] ,A[i][j] < A[i+1][j] ,A[i][j] < A[i][j-1] and A[i][j] < A[i][j+1].
Given an array of n * n , give an O(n) algorithm to find
Share
It’s impossible, unless there are further constraints we haven’t been told about. Each position you investigate can rule out/verify at most 5 positions, so by looking at
kpositions (and their neighbours) you can rule out/verify at most5*kpositions.