[Leetcode] 3392. Count Subarrays of Length Three With a Condition.

Jiya·2025년 4월 27일

Answer

class Solution(object):
    def countSubarrays(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        count = 0
        for i in range(len(nums)-2):
            if nums[i] + nums[i+2] == nums[i+1] / 2:
                count += 1
        return count

오늘부터 리트코드 풀기 시작합니다.
하루에 적어도 한 문제씩 풀 생각입니다.

profile
코딩 공부 노트

0개의 댓글