Company: Meesho SDE - IIT Kanpur
Difficulty: medium
Maximum product Problem Description Given an array A with N integers. Find the maximum subsequence product that can be formed from the elements of this array. Moreover, any pair of index i and index j is present in the same subsequence if and only if their product i*j is a perfect square. Since the answer can be large, output the answer modulo 10 9 + 7 . Notes: Valid subsequence: Let us find a valid subsequence for index 2. Index 2 does not form a valid subsequence with index 3, as 2*3 = 6 which is not a perfect square, whereas index 2 will form a valid subsequence with index 8 as 2*8 = 16 which is a perfect square of 4. You need to find the maximum product of array values at such indices over all valid subsequences. The product must be maximum before taking modulo. 1-based indexing is followed. Function Description Complete the function max_product . This function takes the following 2 parameters and returns the required answer. N : Represents the size of array A A : Represents the el