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.
If I read the precompute correctly. You store first store the 3 base cases, 0,1,2,3 at the same indexes in array.
Then, you build the rest of the array. You overwrite if el == -1 or...the count at num[i] > the count of the previous num + 1. You store the count of the previous num + 1 at the current num, i.
Then, you check the factoring.
You overwrite if el == -1 or the count at current index, i, + 1 is less than the count at the index j * i. You store the count at current number ( index ) + 1 at the index j * i.
Can you elaborate on the section 3?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Down to Zero II
You are viewing a single comment's thread. Return to all comments →
If I read the precompute correctly. You store first store the 3 base cases, 0,1,2,3 at the same indexes in array.
Then, you build the rest of the array. You overwrite if el == -1 or...the count at num[i] > the count of the previous num + 1. You store the count of the previous num + 1 at the current num, i.
Then, you check the factoring. You overwrite if el == -1 or the count at current index, i, + 1 is less than the count at the index j * i. You store the count at current number ( index ) + 1 at the index j * i.
Can you elaborate on the section 3?