分析:要看n-(n+m)是否连续,需要观察(n+1)-(n+m)是否连续。为了防止重复判断,可以引入Hashset,判断n的前提是n-1不在Hashset中。具体操作如下:
1:创建Hashset 。
new HashSet()
Set<Integer> num_set = new HashSet<Integer>();
2:将数组中的值传入到num_set中。
num_set.add(num);
for<
分析:要看n-(n+m)是否连续,需要观察(n+1)-(n+m)是否连续。为了防止重复判断,可以引入Hashset,判断n的前提是n-1不在Hashset中。具体操作如下:
1:创建Hashset 。
new HashSet()
Set<Integer> num_set = new HashSet<Integer>();
2:将数组中的值传入到num_set中。
num_set.add(num);
for<