Sour Candy

Company: Optum

Difficulty: easy

Problem Statement

Sour Candy You are a candy shop owner who keeps a stock of sour candies with different powers of sourness. A customer is shown X candies, given as an array A , where A[i] is the power of sourness of the i -th candy. The customer may pick any non-empty subsequence of these candies (any non-empty subset of positions — the candies do not have to be adjacent). These candies have a peculiar property: once a set of candies is chosen, every candy in the chosen set loses its own strength and takes on the power of sourness of the weakest candy in that set. So if the customer picks k candies whose minimum power of sourness is m , then each of those k candies has power m , and the total power of sourness of the chosen set is k * m . The customer wants the set of candies with the most sourness overall. Report the maximum total power of sourness that can be achieved over all non-empty subsequences. (inferred — the screenshot's Output Specification is cut off. "The set of candies with the most sourn