ā” Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 19m 30s17 days 22 hours 19 minutes 30 seconds.
ā” Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 19m 30s17 days 22 hours 19 minutes 30 seconds.

Sign in to watch this lesson
Advanced - Combinatorics, Games and Puzzles Ā· 4:00
People stand in a circle and every k-th one is removed until one is left. Instead of simulating, we relabel the circle after the first removal and get the recurrence J(n) = (J(n-1) + k) mod n, which runs as a single loop in linear time and constant memory. For k = 2 the survivor has a closed form, two times the distance past the largest power of two, plus one.