2760.最长奇偶子数组

2760.最长奇偶子数组

class Solution(object):
    def longestAlternatingSubarray(self, nums, threshold):
        """
        :type nums: List[int]
        :type threshold: int
        :rtype: int
        """
        # 数组长度
        n=len(nums)
        # 返回结果,和数组下标
        ans=i=0
        while ithreshold or nums[i]%2==1:
                i+=1
                # 不符合跳过
                continue
            l=i
            i+=1
            while i
class Solution(object):
    def longestAlternatingSubarray(self, nums, threshold):
        """
        :type nums: List[int]
        :type threshold: int
        :rtype: int
        """
        # 数组长度
        n=len(nums)
        # 返回结果,和数组下标
        ans=i=0
        while ithreshold or nums[i]%2==1:
                i+=1
                # 不符合跳过
                continue
            l=i
            i+=1
            while i

你可能感兴趣的:(算法,leetcode,数据结构)