We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
You didn't consider the tail part rigorously here.
If the tail value is updated, all the values are reevaluated. This update could lead to another snake-head value update, in turn leading to another series of updates because of the corresponding new-tail update. Thus, the time complexity doesn't remain linear anymore, rather can go as high as exponential. (okay, i didn't put thought in it, i'm just guessing)
But DP isn't a very efficient solution to this.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Snakes and Ladders: The Quickest Way Up
You are viewing a single comment's thread. Return to all comments →
You didn't consider the tail part rigorously here.
If the tail value is updated, all the values are reevaluated. This update could lead to another snake-head value update, in turn leading to another series of updates because of the corresponding new-tail update. Thus, the time complexity doesn't remain linear anymore, rather can go as high as exponential. (okay, i didn't put thought in it, i'm just guessing)
But DP isn't a very efficient solution to this.