Completed the question with input cases passing