Longest Common Prefix Leetcode Solution Java