判断数字集合是否连续递增 判断数字集合是否连续递增 fun judgeBookIllegal(list: ListInt): Boolean { //1,2,3 var firstIndex = list[0]//1 list.forEachIndexed { index, i - if (index 0 i != firstIndex + 1) { ret
判断数字集合是否连续递增
判断数字集合是否连续递增
fun judgeBookIllegal(list: List<Int>): Boolean {
//1,2,3
var firstIndex = list[0]//1
list.forEachIndexed { index, i ->
if (index > 0 && i != firstIndex + 1) {
return false
}
firstIndex = i
}
return true
}