Hackerrank – Strange Counter

Hackerrank – Problem Statement

A description of the problem can be found on Hackerrank.


I calculated time in the cycle when counter value is 1:

last_time_next_cycle = actual_cycle_time + 2 * (last_time_actual_cycle - last_time_previous_cycle).

The difference in seconds between cycle 0 and cycle 1 is 3, which is always like that.

For a given time I calculate its cycle end time. I calculate a difference between given time and calculated cycle end time. Do +1. It is the counter result value.

I created solution in:

All solutions are also available on my GitHub.





Leave a Reply

Your email address will not be published. Required fields are marked *