Write a program to find the largest possible rectangle of letters such that every row forms a word (left to right) and every column forms a word (top to bottom).
Create a Bag[] for word of the same length = index then create an array of Tries, one Trie for wordList of each length
Rectangle makeRectangle(length, height, rectangle)
{
if ( length == rectangle.length()) check if complete and return;
checkIfPartialComplete - check columns for valid prefixes
for ( i from 1 to grouplist[i-1])
{
newRectangle = append word[i] to rectangle
return makeRectangle(l,h, rectangle with appended word) if not equal to null
}
}
boolean checkPartial(int l, Trie trie)
{
for ( int i =0 ; i < l; i++)
{
String col = getColumn(i);
if (!trie.contains(col))
{
return false;
}
}
return true;
}
boolean checkComplete(int l, Bag lengthGroup)
{
for ( int i=0; i < l ; i++)
{
String col = getColumn(i);
if (!lengthGroup.contains(col))
{
return false;
}
}
return true;
}