Problem Statement  
Josh's grandfather has a N x N square field. Each cell in the field is a 1 x 1 square and contains a single type of fruit. Josh's grandfather said to Josh: "You can have any square section of my field, but with one condition. The section must not contain more than two different types of fruits and must not contain fruits of type 0 (zero)." The field contains a maximum of 8 types of fruits. The content of the field can be determined from the String[] changes. Each element of changes is formatted "X Y L F" (quotes for clarity only), where X and Y are the 0based coordinates of the upper left corner of a square area, and L is the length of one side of the square (the upper left corner of the field is at (0, 0)). F is the type of fruit that will be planted in that square area. Initially, each cell contains fruit of type 0. The elements of changes should be applied, in order, to determine the final content of the field. Whenever a new type of fruit is planted in a certain area, it will entirely replace any existing fruit that was there before. Josh is greedy, so he wants to maximize the area of his section. Return the area of the largest square section of the field that contains no more than 2 different types of fruits and doesn't contain fruits of type 0. If no section can be chosen, return 0. See examples and constraints for more clarifications.  
Definition  
 
Constraints  
  N will be between 1 and 1000, inclusive.  
  changes will contain between 0 and 50 elements, inclusive.  
  Each element of changes will be formatted "X Y L F" (quotes for clarity).  
  In each element of changes, X and Y will be integers between 0 and N1, inclusive, with no extra leading zeroes. L will be an integer between 1 and N, inclusive, with no extra leading zeroes. X+L and Y+L will each be between 1 and N, inclusive. F will be an interger between 0 and 7, inclusive, with no extra leading zeroes.  
Examples  
0)  
 
1)  
 
2)  
 
3)  
 
4)  
