In a grid of NXN, you have to find if an element appears k times consecutively (up, down, left, right, diagonal). If yes, return the element else return -1.
If multiple elements exist, return the smallest number.
Input Specification:
input1- The value of N input, A 2-d array representing the grid (all elements ) input3: The value of k
Output Specification:
Returns the smallest element which appears k times consecutively (up. down, left, right, diagonal). If no such element exists, return -1.
Example-
input1:5
input2:
[[3,5,3,9,5],[4,3,2,1,8],[9,4,3,1,9],[8,4,7,6,4],[1,2,5,9,1]]
input3: 3
Output- 3
in this grid,3 is available for 3 times in the diagonal