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.
Dynamic programming (or memoization) and indeterminism!
If we suppose n_ways(A, d) to be a function that returns the total number of distinct ways in distance d from ANY house in a set A, we can compute it recursively:
This was useful in that I was trying to figure out what to call that counter (that stores the current house's reach to its neighbours based on the weights to them) in my House class object
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Clues on a Binary Path
You are viewing a single comment's thread. Return to all comments →
Dynamic programming (or memoization) and indeterminism!
If we suppose n_ways(A, d) to be a function that returns the total number of distinct ways in distance d from ANY house in a set A, we can compute it recursively:
where reach(A, c) gives the set of all houses that can be reached from ANY house in A with given clue (c = 0 or 1).
Then, memoizing n_ways() based on different A and d can boost the performance.
This was useful in that I was trying to figure out what to call that counter (that stores the current house's reach to its neighbours based on the weights to them) in my House class object