cybersecurity · intermediate · ~15 min · safe pentest lab
Find the most common gap between timestamps — the likely beacon period.
Even with noise, the beacon period is usually the most common gap:
int dominant_interval(const int *ts, int n);
Return the most frequent consecutive interval (the mode of the n-1 gaps). On a tie, return the smallest such interval. Return -1 if n<2.
ts sorted ascending, count n.
The modal interval, or -1.
n<2 returns -1; ties resolve to the smallest interval.
#include <stddef.h>
/* ts sorted ascending, n timestamps. Return the most common consecutive interval
(mode of the n-1 gaps); on ties return the smallest such interval. -1 if n<2. */
int dominant_interval(const int *ts, int n){ (void)ts;(void)n; return -1; }
Not handling ties deterministically; returning an index instead of the interval value.
All gaps distinct: any gap is a valid mode (count 1) — the smallest wins.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.