Solve Two String Problems | Amazon Coding Question