Update LongestSubstring.java

improve the speed