Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

How I can find the time complexity of this algorithm?

Правка en1, от annoying, 2020-12-23 12:33:54

I tried to solve the problem on codechef problem COINS. And I have write the following code:

#define long long LL

map<LL,LL> data;   //map DS to store key:value pair
LL solve(LL n){
    if(n<=2)
      return n;
    if(data[n]==0){
      data[n] = max(n,(solve(n/4)+solve(n/3)+solve(n/2)));
    }
    return data[n];
} 

This Link have a very nice discussion on time complexity of this code but I am not able to get any of that. can any one help me out to explain me in detail how can I approch to find the time complexity of this specific problem.

Теги #recursion,dp, #complexity, time complexity

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский annoying 2020-12-23 12:33:54 758 Initial revision (published)