NimbleRx Interview Question

String question, optimize solution much as possible