Longest Common String Leetcode Questions Java