Ctrl K

Strongest Product Team

Medium
The scores of contest participants are given in the array scores; a score can be negative. A coach picks one non-empty team from any of the participants. The strength of a team is the **product** of its members' scores. Return the largest strength a team can have.
Example 1
scores=[2, -3, 0, -4, -1] → 24

Pick 2, −3 and −4: 2 · (−3) · (−4) = 24. Adding −1 would make the product negative, and 0 would wipe it out.

Example 2
scores=[-7, 0] → 0

A one-person team with score 0 gives 0, which beats −7.

Example 3
scores=[-5] → -5

The team must not be empty, so the only option gives −5.

Constraints
  • 1 ≤ len(scores) ≤ 13
  • -9 ≤ scores[i] ≤ 9
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsEdge Toggles on a Tree HardFewest Meetings to Cancel MediumSquare Frame From Sticks MediumSeating by Divisibility MediumCheapest Basket with Bundles Medium
loading Python…
Input
scores=[2, -3, 0, -4, -1]
Expected
24

Run checks the first 3 tests in your browser. Submit checks all 115 tests on the server, hidden ones included.