Controlling Happiness
Alice's summer vacation is N days long. For each day i (0 to N-1), he can choose to do exactly one of three activities: A, B, or C.
The happiness points gained for each activity on day i are given as an array days[i] = [a, b, c].
Alice cannot do the same activity for two or more consecutive days. Find the maximum possible total happiness he can gain by the end of his vacation.
Example 1:
Input : N = 3 , days = [[10, 40, 70], [20, 50, 80], [30, 60, 90]]
Output : 210
Explanation : Choose C on day 0 (70), B on day 1 (50), and C on day 2 (90). Total = 70 + 50 + 90 = 210).
Example 2:
Input : N = 1 , days = [[100, 10, 1]]
Output : 100
Explanation : Choose A (100) on the first day
Now Your Turn!
Pick the correct output for the given inputInput: days = [[10, 20, 30], [40, 50, 60], [100, 10, 10]]
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= N <= 105
- 1 <= a, b, c <= 104