Minimal Fresh Substrings Thanks @NathanMerrill for allowing me to post this! The following is entirely his wording from this sandbox post (deleted):



We define a "Fresh" substring as a substring that is different from any other substring that starts earlier.

For example, if I take the string "abababc" and split it: ["ab","ab","a","bc"], the first and the last substring are fresh, but the middle two are not, because they can be found earlier in the string.

For this challenge, you need create a list of the smallest possible fresh substrings for each position in the string.  If there are no fresh substrings, output and empty list or empty string, etc.

For example, if you were passed "ABABCBA", you should return ["A","B","ABC","BC","C"].

Test Cases:

ABABCBA          A,B,ABC,BC,C,   // ABC instead of AB because there is an AB earlier in the string
AAAAAAA          A,,,,,,
ABCDEFG          A,B,C,D,E,F,G
ABDBABDAB        A,B,D,BA,ABDA,BDA,DA,,
ACABCACBDDABADD  A,C,AB,B,CAC,ACB,CB,BD,D,DA,ABA,BA,AD,,


The empty items are not mandatory.
PHP, 141 bytes



for($r=[];$i&lt;$l=strlen($a=$argn);$i++)for($t=1;$t;$t*=$t&lt;$l)in_array($s=substr($a,$i,$t),$r)|strpos($a,$s)&lt;$i?$t++:$r[]=$s.$t="";print_r($r);


Try it online!