Python, 58 bytes
f=lambda s,p='':s>''and(f(p)>-(s==p)<f(s))|f(s[1:],p+s[0])
This is based on the Dennis's recursive methodDennis's recursive method. The Boolean negation trick is taken from there as well.
The new idea is to recurse over partitions (p,s)
of the original string by starting with ('',s)
and repeatedly moving the first character of s
to be the last character of p
. This allows for the parts to be referred to directly without string slicing. But, because the partition starts with p
empty, we must be careful to avoid infinite loops of f(s)
calling f(s)
.