题解 | #区间表达#

区间表达

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)
全部评论

相关推荐

12-15 14:16
门头沟学院 Java
回家当保安:发offer的时候会背调学信网,最好不要这样。 “27届 ”和“28届以下 ”公司招聘的预期是不一样的。
实习简历求拷打
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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