题解 | #区间表达#

区间表达

http://www.nowcoder.com/practice/13817b2007014974987046deeb7f9dbf

python 3解法
如果列表中的数字不是连续的,就需要一个区间
如果是连续的,就需要一个一直连续的就行,首先默认count == 1

numbers = int(input())
list_1 = list(map(int,input().strip().split()))
count = 1
for item in range(len(list_1)-1):
    if list_1[item] +1 != list_1[item+1]:
        count += 1
print(count)
全部评论

相关推荐

04-16 19:19
已编辑
合肥大学 Java
刷了100道题的大老虎很想提桶:27届现在早没日常hc了,不可能找到的,等暑假9月吧
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务