Positive Product

Company: Arcesium_17oct

Difficulty: medium

Problem Statement

Positive Product Problem Description You are given a sequence of `n` non-zero integers. Find the maximum length of a contiguous segment of the sequence whose product is positive. A segment is a block of consecutive elements of the sequence. Its product is positive when the segment contains an even number of negative elements. If no non-empty segment has a positive product, the answer is `0`. Complete the `maxLength` function in your editor. It has one parameter: An array, `arr`, containing the `n` elements of the sequence. It must return an integer denoting the maximum length of a contiguous segment whose product is positive. Input Format The locked stub code in your editor reads the following input from stdin and passes it to your function: The first line contains the number of integers `n` in the sequence. Each of the next `n` lines contains one element of the sequence. Output Format Your function must return an integer denoting the maximum length of a contiguous segment whose produc