UST Interview Question

related to string, frog hop problem