Solved Longest Common Prefix problem