UST interview question

related to string, frog hop problem