Robinhood interview question

string manipulation, dynamic programming / optimization