A teacher wants to form the strongest possible study group from students based on their exam scores! ๐
Given a 0-indexed integer array nums representing student scores, you need to select any non-empty subset of students to maximize the group's strength.
The strength of a group is calculated by multiplying all selected scores together. For example, if you select students with scores [2, -3, 4], the strength would be 2 ร (-3) ร 4 = -24.
Goal: Return the maximum possible strength you can achieve by selecting the optimal group of students.
Key Insight: Since we're dealing with multiplication, negative numbers can become positive when paired together, and we want to maximize the final product!
Input & Output
Constraints
- 1 โค nums.length โค 13
- -9 โค nums[i] โค 9
- Note: Small constraints allow for brute force solutions