3 ms·
Instead of a linked list I would have: allocated an array of size 10 an int i that increments on every call mod 10 Each successful call puts the current time
by jallen_dot_dev 5y ago
Instead of a linked list I would have:
allocated an array of size 10
an int i that increments on every call mod 10
Each successful call puts the current timestamp in array[i] and increments i. On each attempt to call, you check if array[i] is > 1 minute ago. This way you are only ever checking 1 array element instead of potentially deleting multiple list items and counting.