Notification days
Write code · Medium · §10.1 Recursion that repeats work
You are choosing the days to send a push notification about a new feature. The days are numbered from 0 in order, and clicks[i] is the expected number of clicks if the notification is sent on day i. Users turn notifications off if they get them two days in a row, so the notification is never sent on two neighboring days.
Complete the function solution, which chooses the days to send the notification and returns the largest possible total of expected clicks. You may choose any number of days.
Function
solution(clicks)
Constraints
- The length of
clicksis from 1 to 365. - Each element of
clicksis an integer from 0 to 10,000.
Examples
| clicks | result |
|---|---|
[5, 1, 4, 2, 6] | 15 |
[1, 6, 2, 7] | 13 |
Starter code
def solution(clicks):
answer = 0
return answerSolve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.