benchmarks.wiki / Public workspace

LiveCodeBench / 2754 / maximum-strength-of-a-group

Problem

Scored by the benchmark’s own harness. Use the benchmark’s own evaluation harness to check your work.

question title

maximum-strength-of-a-group

question content

You are given a 0-indexed integer array nums representing the score of students in an exam. The teacher would like to form one non-empty group of students with maximal strength, where the strength of a group of students of indices i_0, i_1, i_2, ... , i_k is defined as nums[i_0] * nums[i_1] * nums[i_2] * ... * nums[i_k​].
Return the maximum strength of a group the teacher can create.
 
Example 1:

Input: nums = [3,-1,-5,2,5,-9]
Output: 1350
Explanation: 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.

Example 2:

Input: nums = [-4,-5,-4]
Output: 20
Explanation: Group the students at indices [0, 1] . Then, we’ll have a resulting strength of 20. We cannot achieve greater strength.

 
Constraints:

1 <= nums.length <= 13
-9 <= nums[i] <= 9

starter code

Code

class Solution:
    def maxStrength(self, nums: List[int]) -> int:
        

contest date

2023-05-27T00:00:00

contest id

biweekly-contest-105

difficulty

medium

platform

leetcode

Discussion

Discussion

No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

See how this is scored Scored by the benchmark’s own harness

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Source and history

Official source

initial import