Sir, i'm getting run time error. please help me to figure our my mistake
hello @chandreshmaurya
value of n can be upto 10^9. so u cant use array and bottom up dp.
use map for memoisation.
sir, yha pe " dp[n]=max(n,solve(n/2,dp)+solve(n/3,dp)+solve(n/4,dp)); " βnβ ko check nhi karenge ? ki ye 2,3,4 se divisible hai ya nhi ?
no , β¦u can do direct division
kyo sir ? β
it is said nowhere in the question
sir, I have 2 doubts. 1st is -> if n = 15 given hai to. kya ham " n/2 = 7, n/3 = 5 , n/4 = 3 " se maxm find krenge ? 2nd is -> hamlog ( if(n<12) dp[n] = n ; return n ) , n<12 ke liye ye condition kyo use kar rhe hain ?
sir, isme aap βn<12β ke liye βnβ return q kra rhe hainβ¦ use bhi " max(n, solve(n/2)+solve(n/3)+solve(n/4)) " kqo nhi kar rhe hain ?