UST interview question

basic theory , and coding