Largest Product After Decrementing Two Distinct Entries
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Other
### Problem
Choose two different array indices i and j. Return the maximum value of(nums[i]-1)*(nums[j]-1). Equal numeric values at different positions may both be chosen.
```cpp
class Solution {
public:
int maxProduct(vector<int>& nums);
};
```
### Examples
**Example 1:**
```text
Input: nums = [2,6,6]
Output: 25
Explanation: The two different positions containing6 give5*5=25.
```
**Example 2:**
```text
Input: nums = [1,9]
Output: 0
Explanation: Both entries must be used and(1-1)*(9-1)=0.
```
### Constraints
- nums has length 2 to 500.
- `1 <= nums[i] <= 1000`.
### Contract considerations
Return the product value, not the selected indices.
```hint Read the boundary condition
The selected indices must differ, but their values may agree. Include values at the lower bound and return the requested product value.
```
### Boundary reminders
Return the product value, not the selected indices.
Overview: Largest Product After Decrementing Two Distinct Entries. Choose two different array indices i and j.