当前位置: 代码迷 >> 综合 >> exercism————Series
  详细解决方案

exercism————Series

热度:75   发布时间:2023-12-13 18:10:19.0

题目:

在这里插入图片描述

解法:

 Set<List<Character>> getAllSubSet(String str, int digits) {
    // check the inputif (str.matches("[^0-9]") || digits > str.length()) {
    throw new IllegalArgumentException("Invalid input");}// put every subSet into resultSet<List<Character>> result = new HashSet<>();for (int i = 0; i < (str.length() - digits + 1); i++) {
    List<Character> subSet = new ArrayList<>();for (int j = 0; j < digits; j++) {
    subSet.add(str.charAt(i + j));}result.add(subSet);}return result;}
  相关解决方案