C3 AI interview question

I had to take a HackerRank test.