Bootcamps
Masterclasses
Menu
Courses
Account
Login / Sign Up

Maximum Product Of Two Numbers

Basic Acceptance 81.34% Points 10

You are given an array arr[] of non-negative integers, return the maximum product of two numbers possible.

Examples
Example 1

Example 1

Input: arr[] = [1, 4, 3, 6, 7, 0]

Output: 42

Explanation: 6 and 7 have the maximum product.

Example 2

Example 2

Input: arr[] = [1, 100, 42, 4, 23]

Output: 4200

Explanation: 42 and 100 have the maximum product.

Constraints
  • 2 <= arr.size <= 10^7
  • 0 <= arr[i] <= 10^9
Hints
  • Expected Time Complexity: O(n)
  • Expected Auxiliary Space: O(1)
Topics
Array Sorting Algorithms
Companies
Amazon
Added 30 Nov 2024 81.34% acceptance
Ln 1, Col 1Sign in to save your code
1 100 42 4 23
4200