SETU Off-Campus OA (2024) | Maximum Product of Two Elements in an Array

Question · Posted Jun 2026

Maximum Product of Two Elements in an Array Problem Statement You are given an integer array nums. Choose two different indices i and j such that the value of (nums[i] - 1) * (nums[j] - 1) is maximized. Return the maximum possible product. Example Input nums = [3,4,5,2] Output 12 Explanation The two largest numbers are 5 and 4. Maximum product: (5 - 1) × (4 - 1) = 4 × 3 = 12 Constraints 2 <= nums.length <= 500 ...

The full answer & interview discussion are available to premium members.

Log in Create a free account