Jobsity interview question

Classic algorithmic problems (easy to medium)