Longest Common Substring Problem Leetcode Java