Company: Cohesity_28aug

Difficulty: medium

Problem Statement

Greatest Product of Two Elements in Array Problem Description Given an array a , find the largest value in a that equals the product of two elements of a , where the two elements sit at different positions (their values may still coincide). If no such pair exists whose product also appears in a , return -1. Examples Example 1: Input: a = [10, 3, 5, 10, 15] Output: 30 Explanation: 30 is a product of 10 and 3. Example 2: Input: a = [2, 3, 7, 8] Output: -1 Example 3: Input: a = [10, 2, 4, 30, 35] Output: -1 Example 4: Input: a = [10, 2, 2, 4, 30, 35] Output: 4 Explanation: 4 is a product of 2 and 2. Constraints 1 <= a.length <= 10^3 1 <= a[i] <= 10^9 ```

More Cohesity_28aug OA questionsInterview experiences