First version of the Longest common prefix problem.

When handling special cases, think about the trade-offs, does it worth the effort?
E.g. check in each loop, return  when 'compare' is equal to empty string