题目描述
思路分析
看到不同,想到set去重
截取想到String.substring()
代码实现
package com.atguigu.TEST;import java.util.HashSet;
import java.util.Set;class Main{public static void main(String[] args) {String target="0100110001010001";Set<String> sub = new HashSet<>();for (int i = 0; i < target.length(); i++) {for (int j = i+1; j <=target.length(); j++) {sub.add(target.substring(i,j));}}System.out.println(sub.size());}}
答案
100