Cboe Interview Question

What is another way you could have solved the coding challenge?