P15184 [GeeksforGeeks] Maximum product subset of an array
普及
题目描述

Given an array A[]. The task is to find the maximum product possible with the subset of elements present in the array. The maximum product can be a single element also.
Since the product can be large, return it modulo (10^{9} + 7).
Example 1:
Input:
A[] = {-1, -1, -2, 4, 3}
Output: 24
Explanation: Maximum product will be ( -2 * -1 * 4 * 3 ) = 24
Example 2:
Input:
A[] = {-1, 0}
Output: 0

Your Task:
You don't need to read input or print anything. Your task is to complete the function findMaxProduct() which takes an array of size N and returns an integer.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Constraints:
1 <= N <= 2 * 10^{4}
-10 <= A[i] <= 10

输入格式

见题面

输出格式

见题面

样例输入
A[] = {-1, -1, -2, 4, 3}
样例输出
24