GlobalLogic interview question

oops concept, coding round