Optum interview question

Medium level coding question based on strings