8 replies
Monkeym
over 5 years ago
erickson-balanga
over 5 years ago

An element is a peak element if it is greater than or equal to its four neighbors, left, right, top and bottom. For example neighbors for A[i][j] are A[i-1][j], A[i+1][j], A[i][j-1] and A[i][j+1]. For corner elements, missing neighbors are considered of negative infinite value.
Examples:
Input : 10 20 15
21 30 14
7 16 32
Output : 30
30 is a peak element because all its
neighbors are smaller or equal to it.
32 can also be picked as a peak. Input : 10 7
11 17
Output : 17
30 is a peak element because all its
neighbors are smaller or equal to it.
32 can also be picked as a peak. Input : 10 7
11 17
Output : 17
100%
to see other 6 answers
Related documents
Search questions by subject

