Coddy Active Users
Lesson 3 of 3 in Coddy's Interview Coding Challenges - Pack III course.
Not all of Coddy's registered users are active.
The recursion function that represents Coddy's weekly active users is a calculation which involves both previous registered users (from last challenge) and also previous active users:
If previous week had x1 users and x2 active users, and this week had y1 users and y2 active users, Coddy is going to have x1+x2+y1+y2 active users next week.
Coddy had 0 active users in the first week and 1 active user in the second week.
Challenge
HardWrite a function getActiveUsers which gets an integer n and returns the amount of active users Coddy has in the n'th week modulo 109 + 7.
Constraints:
1 < n < 100
Example 1,
Input: 3
Expected output: 2
Explanation: in that case x1=x2=0, y1=y2=1, therefore there would be 0+0+1+1=2 active users in the third week.
Example 2,
Input: 4
Expected output: 7
Explanation: 2+3+1+1=7.
Example 3,
Input: 5
Expected output: 22
Explanation: 2+3+10+7=22.
Try it yourself
int getActiveUsers(int n) {
// Write code here
}