String Question In Java Leetcode Longest