Leetcode 1464: Maximum product of two elements in an array

Pierre-Marie Poitevin
1 min readJun 12, 2020

In this Leetcode problem, we are asked to compute the maximum product of 2 elements in the array, knowing that the elements are positive.

Problem statement

Solution

  1. According to the constraints, all numbers are positive ( >0 )
  2. Therefore the problem is equivalent to finding the 2 highest numbers in the array (a, b), and return…

--

--