Twilio interview question

Hackerrank assessment involving string manipulation, DP