I am solving this question from leetcode…
983. Minimum Cost For Tickets
I have thought the logic and also implemented that, But it is showing wrong answer.
This is my solution…
Could you please look this into…
I am solving this question from leetcode…
983. Minimum Cost For Tickets
I have thought the logic and also implemented that, But it is showing wrong answer.
This is my solution…
Could you please look this into…
This is updated code… But it is also showing wrong output…
hello @ashishnnnnn
what logic u r using ?
this is a dp related problem
let say we are at ith day then two cases arises ->
if i is not given in days list -> dp[i]=dp[i-1] // as we dont want to buy pass for this day
if i is given in days list ->
dp[i]= min of
dp[i-1] + cost of pass for 1 day
dp[i-7] + cost of pass for 7 day
dp[i-30]+ cost of pss of 30 day
at the end simply return dp[365]
I am also trying to implement that with help of dp.
Here i have written only recursive solution but not done memoization…
But The recursive solution is also showing wrong answer.
So first i want to correct that recursive solution…
My logic is same as the logic explained in this video…