Two Sigma interview question

Several questions involving strings and graphs.