Naive pseudocode alogrithm:
int minMatchLen = 3; // The minimum length of string match required
string stringArray[] = {"person", "twolegperson", "animal", "animalgold"}
for (i = 0; i < stringArray.length, i++) {
int strLen = stringArray[i].length;
for (substrIndex = 0; substrIndex < strLen - minMatchLen; substrIndex++) {
for (substrLen = minMatchLen; substrLen < strLen - substrIndex; substrLen++) {
string subString = stringArray[i].substr(substrIndex, substrLen);
bool matchFound = false;
for (j = i + 1; j < stringArray.length; j++) {
if stringArray[j].contains(subString) {
print("String '" + subString + "' found in '" + stringArray[j] + "'");
matchFound = true;
}
}
if (matchFound) print(""String '" + subString + "' found in '" + stringArray[i] + "'");
}
}
}
This basically goes through each string in the array, extracts all possible substrings over a specified minimum length, and then search the strings in the remainder of the array for those substrings. I'm sure there are more elegant and efficient solutions, but this will get the job done. It'll probably be slow for a large array, though.