I am trying to understand, what is the best way to answer this question. My attempt is below and I am able to pass all test cases but i\'m not sure if this is the best way t