Finding greatest product pairs

Question

Suppose you're given an array of n elements. Within this array, return the greatest value of a single element that is the product of two elements contained within the same array. If no such product exists, print N/A. Lastly, you can assume that the values within the array are positive integers.

For example:

Input: array = [2, 2, 4, 5, 9] 
Output: 4 #(since 2 * 2 = 4)

Input: array = [1, 3, 4, 7, 10] 
Output: 10 #(since 1 * 10 = 10)

Input: array = [3, 3, 4, 7, 10] 
Output: N/A

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now