Challenge: Find the Maximum Product of Two Integers in an Array

Solve the challenge of finding the maximum product of two integers in an array of numbers.

Problem statement

Implement a function called FindMaxProduct(arr) that takes an array of numbers and returns a maximum product pair.

Input

An array of integer numbers.

Output

A pair of integers that produces the maximum product.

Sample input

arr = {1, 3, 5, 2, 6};

Sample output

(result1, result2) = (5, 6);

Coding exercise

Take a close look at this problem and design a step-by-step algorithm first before jumping to the implementation. This problem is designed for your practice, so try to solve it on your own first. If you get stuck, you can always refer to the solution provided in the solution section. Good luck!

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.