better solution for longest common prefix

Signed-off-by: Mory Mobile <mory.mobile@gmail.com>
best way for longest common prefix

Signed-off-by: Mory Mobile <mory.mobile@gmail.com>