2025-08-22 15:48:54 +0000 UTC

Maximum Number of Operations With the Same Score I

Code

class Solution:
    def maxOperations(self, nums: List[int]) -> int:
        target = sum(nums[:2])
        res = 1
        for i in range(2, len(nums) - 1, 2):
            if sum(nums[i:i + 2]) == target:
                res += 1
            else:
                break
        return res