The following question was asked in advanced programming section and time limit was 45 min.
A garden is in the form of grid and plant types are numbers from 0, 1, 2, .... Every cell can have one type of plant. You have to pick plants such that two type of plant are selected and the connected area formed by these two types if the maximum.
Sample test case:
1 1 3
2 1 2
1 3 4
Output: 6
Explanantion: The maximum connected area is covered by plant type 1 and 2
Sample TC2:
1 1 2
1 1 1
3 3 3
Output: 8
Explanation: Maximum connected area formed by plant type 1 and 3.
Constraints:
1<=Row<=2000
1<=Column<=2000
It would be helpful if someone posts approach to the problem.