Leetcode Longest Common Substring In Java