You are viewing a single comment's thread. Return to all comments →
My O(n) solution:
collect following 4 parameters at each of n steps:
Initially (before first step) there is 1 node, and other values are zeros. Calculate values for current step from previous step values in O(1).
Seems like cookies are disabled on this browser, please enable them to open this website
HackerRank City
You are viewing a single comment's thread. Return to all comments →
My O(n) solution:
collect following 4 parameters at each of n steps:
Initially (before first step) there is 1 node, and other values are zeros. Calculate values for current step from previous step values in O(1).