Coddy Users (long term)
Lesson 2 of 3 in Coddy's Interview Coding Challenges - Pack III course.
Each week, Coddy has more users than the previous week. The recursion function that represents Coddy's weekly users goes like this:
If previous week had x users, and this week had y users, Coddy is going to have x + 3y users in the next week.
Coddy had 0 users in the first week and 1 user in the second week.
Challenge
MediumWrite a function getUsers which gets an integer n and returns the amount of users Coddy has in the n'th week modulo 109+7.
Constraints:
1 < n < 100
Notice we are looking for much bigger numbers now, recursion approach won't be good enough - results in timed out.
Try it yourself
int getUsers(int n) {
// Write code here
}