Bitsight Interview Question

to implement an algorithm, based on their prompt.