LeetCode: Longest Repeating DNA Sequence

Problem statements:

Examples:

Constraints:

Solution Approach:

Solution:

      public List<String> findRepeatedDnaSequences(String s) {
          int len = 0;
          if(s == null || s.isBlank() || (len = s.length()) < 10 || len > 100000) {
            return Collections.emptyList();
          }
          
          Set<String> ss = new HashSet<>(), res = new HashSet<>();
          
          for(int i = 0; i <= len - 10; i++) {
              String t = s.substring(i, i + 10);
              if(!ss.add(t)){
                  res.add(t);
              }
          }
          return new ArrayList<>(res);
      }

------ End ------