Microsoft interview question

OA at Codility easy-mid leetcode question