更新 Solution.java

master
wangsiyuan 2023-09-04 18:39:55 +08:00
parent 87b994cf7d
commit ce26795849
1 changed files with 13 additions and 0 deletions

View File

@ -1,2 +1,15 @@
import java.util.HashSet;
import java.util.Set;
public class Solution {
public int lengthOfLongestSubstring(String s) {
if (s != null){
Set<Character> stringList = new HashSet<>();
for (int i = 0; i < s.length(); i++) {
stringList.add(s.charAt(i));
}
return stringList.size();
}
return 0;
}
}