marks (values may repeat). A grasshopper starts on one of the marks and then only jumps forward, exactly stride each time. It visits v, v + stride, v + 2·stride, … and covers every mark at those positions.
The starting point must be a value from marks. Pick the start that covers as many marks as possible (each array element counts separately). If several starts tie, return the smallest one.marks=[4, 10, 7, 1, 13, 2], stride=3 → 1
Starting at 1 gives hops 1, 4, 7, 10, 13, … — five of the six marks are hit, everything but 2.
marks=[9, 5, 14, 6], stride=4 → 5
Starting at 5 hits 5 and 9, starting at 6 hits 6 and 14. That is two marks either way, so the smaller value, 5, wins.
marks=[8, 3], stride=50 → 3
marks=[4, 10, 7, 1, 13, 2], stride=3
1
Run checks the first 3 tests in your browser. Submit checks all 127 tests on the server, hidden ones included.