Candy Problem

Candy Problem — ExecCode Hard DSA Practice

Solve the Candy problem on ExecCode. Free online hard DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Candy. Two-pass slope candy counts. For Candy, focus on the exact input variables, return only the requested value, and preserve the required time complexity for the intended pattern.

Examples

Input {"ratings": [1, 0, 2]}; Output 5

Constraints

1 ≤ n ≤ 10^5

Practice Candy free on ExecCode. Browse DSA problems, topic map, and placement guides.