C ++ program for the above approach
#include <bits/stdc++.h> NEW_LINE #define row  6 NEW_LINE #define col  7 NEW_LINE using namespace std ; int vis [ row + 1 ] [ col + 1 ] , id ; int diameter = 0 , length = 0 ;