1 minute read

Given a list of integers nums, find the largest product of two distinct elements.

Constraints

  • n ≤ 100,000 where n is the length of nums

https://binarysearch.com/problems/Max-Product-of-Two-Numbers

Examples

Example 1

Input

  • nums = [5, 1, 7]

Output

  • answer = 35

Explanation

35 is the largest product that can be made from 5 * 7

Example 2

Input

  • nums = [7, 1, 7]

Output

  • answer = 49

Explanation

49 is the largest product that can be made from 7 * 7. The values can be the same but they must be separate elements.

Example 3

Input

  • nums = [-5, 1, -7]

Output

  • answer = 35

Explanation

35 is the largest product that can be made from -5 * -7.

Solution

Categories:

Updated:

Leave a comment