New to Leetcode Need explaination

Hi,
I am new to this community and overwhelmed by the types of discussions that are going on here.
The purpose I joined this website is to Improve my knowledge on Data Structure and Algortihms and this is first day on this platform.

Today I attemped first question and while looking into my my submission details. I've found some strange things everytime I submit the same solution again and again the runtimes are different.

Is there something that I'm doing incorrect or it's just a dev thing in my mind.

class Solution:
    def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
        max_cnt = 0
        cnt = 0
        
        for i in nums:
            if i == 1:
                cnt += 1
                
                max_cnt = max(max_cnt, cnt)
                
                # if max_cnt < cnt:
                #     max_cnt = cnt
            else:
                cnt = 0
                
        return max_cnt

Submission Details

1. Runtime: 364 ms
Memory Usage: 14 MB

2. Runtime: 384 ms
Memory Usage: 14 MB

3. Runtime: 444 ms
Memory Usage: 14 MB

4. Runtime: 464 ms
Memory Usage: 14.2 MB

5. Runtime: 576 ms
Memory Usage: 13.9 MB

6. Runtime: 376 ms
Memory Usage: 14 MB

Every time I submitted runtimes are different

Comments (1)