Back to course home
0% completed
Vote For New Content
Solution: Maximum Length of Subarray With Positive Product
Problem Statement
Given an integer array nums, find the maximum length of a subarray where the product of all its elements is greater than 0.
A subarray is a sequence of consecutive elements from the original array.
Examples
-
Example 1:
- Input:
nums = [1, -2, 3, 4] - Expected Output:
2 - Justification: The longest subarray with a positive product is
[3, 4], with a length of 2.
- Input:
-
Example 2:
- Input:
nums = [-1, -2, -3, -4] - Expected Output:
4
- Input:
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible