알고리즘/LeetCode

[LeetCode/Learn/Array101] Max Consecutive Ones

heeyaaa! 2023. 2. 11. 14:29
SMALL

 

문제

https://leetcode.com/explore/featured/card/fun-with-arrays/521/introduction/3238/

 

Explore - LeetCode

LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore.

leetcode.com

 

풀이

  • python으로 풀었습니다.

리스트 nums에 들어가는 num이 1이면 하나씩 카운트를 하고 현재 count와 result 중 비교하여 큰 값을 result로 받게 했습니다. 

리스트 nums에 들어가는 num이 0이면 count를 0으로 다시 초기화 시킵니다.

 

 

LIST