创建 Solution.java
This commit is contained in:
17
src/solution/Solution.java
Normal file
17
src/solution/Solution.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package solution;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user