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.
A closed form solution is possible. You can calculate which column the t is in. From that you can calculate what the 1st time and value in that column will be. After that, calculating the value corresponding to t is trivial.
Hint:
Notice that the number of elements in each column form a geometric series: 3, 6, 12, ..., 3 * 2^(column - 1)
You can use (or derive) the formula for the sum of a geometric series to figure out how many elements there are, in total, in the 1st n columns.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Strange Counter
You are viewing a single comment's thread. Return to all comments →
A closed form solution is possible. You can calculate which column the t is in. From that you can calculate what the 1st time and value in that column will be. After that, calculating the value corresponding to t is trivial.
Hint: Notice that the number of elements in each column form a geometric series: 3, 6, 12, ..., 3 * 2^(column - 1)
You can use (or derive) the formula for the sum of a geometric series to figure out how many elements there are, in total, in the 1st n columns.