GlobalLogic interview question

Write codes for some common problems.: