Tap here to switch tabs
Problem
Submissions

Problem: Maximum Length of Subarray With Positive Product

Maximum Length of Subarray With Positive Product asks you to find the longest contiguous subarray in an integer array whose product is positive, returning its length or zero.

Statement

Given an array of integers nums, determine the maximum length of a contiguous subarray whose elements have a strictly positive product.

Return the maximum length found. If there is no subarray with a positive product, return 00.

Note: A subarray is a contiguous sequence of elements within an array. A product equal to 00 is not considered positive.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Length of Subarray With Positive Product

Maximum Length of Subarray With Positive Product asks you to find the longest contiguous subarray in an integer array whose product is positive, returning its length or zero.

Statement

Given an array of integers nums, determine the maximum length of a contiguous subarray whose elements have a strictly positive product.

Return the maximum length found. If there is no subarray with a positive product, return 00.

Note: A subarray is a contiguous sequence of elements within an array. A product equal to 00 is not considered positive.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9