longest common prefix

find minlength and then check