Back to Browse

1464. Maximum Product of Two Elements in an Array | LeetCode Easy | C++ Solution

5 views
May 18, 2026
5:29

Problem Name: 1464. Maximum Product of Two Elements in an Array In this video, I solved the LeetCode Easy problem “Maximum Product of Two Elements in an Array” using C++ with a step-by-step explanation. 📌 Problem Statement: Given an integer array nums, choose two different indices i and j such that: (nums[i] - 1) * (nums[j] - 1) is maximum. Return the maximum value. 📌 Approach Used: - Use two nested loops - Check every possible pair - Calculate product: (nums[i] - 1) * (nums[j] - 1) - Store the maximum product using max() 📌 Concepts Covered: ✅ Arrays ✅ Nested Loops ✅ Brute Force Approach ✅ STL max() ✅ Pair Comparison 📌 Example: Input: nums = [3,4,5,2] Output: 12 Explanation: Choose 5 and 4 (5 - 1) * (4 - 1) = 4 * 3 = 12 📌 Time Complexity: O(n²) 📌 Space Complexity: O(1) 📌 Language Used: C++ 📌 Features: ✅ Beginner Friendly ✅ Step-by-Step Explanation ✅ Dry Run Included ✅ Interview Preparation ✅ Easy C++ Solution 🔗 GitHub: https://github.com/amankumar1508 🔗 LinkedIn: / aman-kumar-067825379 🔗 Portfolio: https://aman-kumar-dev-portfolio.verc... 🔗 LeetCode Profile: https://leetcode.com/u/OVzm6rcAP2/ #leetcode #cplusplus #cpp #leetcode1464 #dsa #coding #programming #arrays

Download

0 formats

No download links available.

1464. Maximum Product of Two Elements in an Array | LeetCode Easy | C++ Solution | NatokHD