You are viewing a single comment's thread. Return to all comments →
Instead of using two arrays, compare the center matrix (formed excluding boundary values) while printing the matrix..! ;)
if( (i>=1)&&(i<n-1) && (j>=1)&&(j<n-1) )
if( (a[i][j] > a[i-1][j]) && (a[i][j] > a[i][j+1])
&& (a[i][j] > a[i+1][j]) && (a[i][j] > a[i][j-1]) )
if we replace %1d with %d... why the input contains extra zeros?? what is the significance of 1? can you please explain..
%1d signifies read 1 digit at a time. If you write %d, one entire row of digits will be read at once, which is not what you want.
okay.. thank u
thank you for the code
I had also gone with the same logic..but the problem is that some test cases contain spaces whereas some test cases don't have spaces..
Please help me on that..
M = grid
N = len(M)
for i in range(N):
for j in range(N):
if not ( i in [0,N-1] or j in [0,N-1] ):
c = M[i][j]
if M[i-1][j] < c and M[i+1][j] < c and M[i][j-1] < c and M[i][j+1] < c :
temp = M[i]
temp = list(temp)
temp[j] = 'X'
for j in temp:
M[i] = temp2