题解 | #数字在升序数组中出现的次数#
https://www.nowcoder.com/practice/70610bf967994b22bb1c26f9ae901fa2
import java.util.*; public class Solution { public boolean IsContinuous(int [] numbers) { Arrays.sort(numbers); int len = 0; for(int i = 0; i < numbers.length - 1;i++){ if(numbers[i] == 0){ len++; continue; } if(numbers[i + 1] - numbers[i] > len + 1){ return false; }else if(numbers[i + 1] - numbers[i] == 0){ return false; }else if(numbers[i + 1] - numbers[i] <= len + 1){ len = len - (numbers[i + 1] - numbers[i]) + 1; } } return true; } }