Varicent interview question

Solve a easy-medium coding problem