首页 > 其他 > 详细

HR_Jumping on the Clouds

时间:2018-09-30 19:29:05      阅读:185      评论:0      收藏:0      [点我收藏+]

1.没有考虑i+2越界的问题

2.没有考虑结尾三个零导致 -5

3.没有考虑len(c)<2 导致 -5

 

#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the jumpingOnClouds function below.
def jumpingOnClouds(c):

    count = 0
    i = 0
    while(i + 2 < len(c)):
        if c[i+2] == 0:
            count = count + 1
            i = i + 2
        else:
            count = count + 1
            i = i + 1
    if len(c)<=2:
        count = count + 1
    else:
        if c[-2] == 0 and c[-3] == 1:
            count = count + 1

    return count


if __name__ == ‘__main__‘:
    fptr = open(os.environ[‘OUTPUT_PATH‘], ‘w‘)

    n = int(input())

    c = list(map(int, input().rstrip().split()))

    result = jumpingOnClouds(c)

    fptr.write(str(result) + ‘\n‘)

    fptr.close()

  

HR_Jumping on the Clouds

原文:https://www.cnblogs.com/alfredsun/p/9732935.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!