Company: LeadSquared_8aug
Difficulty: medium
BIG Neighbors Circle Problem Description You are given a matrix of size n*m. Each matrix element is either 0 or 1. 1 denotes that there is a House and 0 denotes there is a Park. You have to determine the largest house group or one that has a maximum number of neighbors. The neighbour of the house at position (i,j) will be the house at positions (i, j+1), (i, j-1), (i-1, j), (i+1, j). For better understanding see Sample Testcase. Input Format First-line contains an integer n denoting the number of rows. The next line contains an integer m denoting the number of columns. Next, n lines contain m space-separated matrix values i.e. either 0 and 1. Constraints 1 <= n,m <= 2000 matrix[i][j] can be 0 or 1. Output Format Print the biggest neighbour size. Examples Example 1: Input: 4 5 0 1 0 0 1 1 0 1 0 0 1 1 1 1 0 0 0 0 1 1 Output: 8 Explanation: There are 3 groups: [[0,1]] [[1,0], [2,0], [2,1], [2,2], [1,2], [2,3], [3,3], [3,4]] [[0,4]] The biggest group among these 3 are [[1,0], [2,0],