Upwork Interview Question

Basic algorithms.