Class Solution
java.lang.Object
g2701_2800.s2708_maximum_strength_of_a_group.Solution
2708 - Maximum Strength of a Group.<p>Medium</p>
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> representing the score of students in an exam. The teacher would like to form one <strong>non-empty</strong> group of students with maximal <strong>strength</strong> , where the strength of a group of students of indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, … , <code>i<sub>k</sub></code> is defined as <code>nums[i<sub>0</sub>] * nums[i<sub>1</sub>] * nums[i<sub>2</sub>] * … * nums[i<sub>k</sub>]</code>.</p>
<p>Return <em>the maximum strength of a group the teacher can create</em>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [3,-1,-5,2,5,-9]</p>
<p><strong>Output:</strong> 1350</p>
<p><strong>Explanation:</strong> One way to form a group of maximal strength is to group the students at indices [0,2,3,4,5]. Their strength is 3 * (-5) * 2 * 5 * (-9) = 1350, which we can show is optimal.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [-4,-5,-4]</p>
<p><strong>Output:</strong> 20</p>
<p><strong>Explanation:</strong> Group the students at indices [0, 1] . Then, we\u2019ll have a resulting strength of 20. We cannot achieve greater strength.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 13</code></li>
<li><code>-9 <= nums[i] <= 9</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
maxStrength
public long maxStrength(int[] nums)
-