diff --git a/src/solution/Solution.java b/src/solution/Solution.java new file mode 100644 index 0000000..cfbaae7 --- /dev/null +++ b/src/solution/Solution.java @@ -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 stringList = new HashSet<>(); + for (int i = 0; i < s.length(); i++) { + stringList.add(s.charAt(i)); + } + return stringList.size(); + } + return 0; + } +}