GE interview question

Codility OA - two very easy questions