Question from today's CodeFusion contest on Codechef.
Link to the problem : https://www.codechef.com/CFUS2020/problems/CFS2003/ Link to my solution : https://www.codechef.com/viewsolution/38007484
Can someone please help me with where I might be going wrong with my approach? Also kindly help me with the correct solution as well.
dp[i] - stores the minimum jumps to reach ith step cnt[i] - stores the number of ways to reach ith step using minimum jumps (i.e dp[i]) And I keep inp[i], where if inp[i] = 1 then there is a portal at that step otherwise not And I keep prevPor[i], which indicates position of previous portal Transition are defined below (while taking given constraints into considerations) dp[i] = min(dp[i-1] + 1, dp[i-2] + 1, dp[index(prevPortal)] + 1)