Two Sigma interview question

String chains hacker rank