Deloitte interview question

LeetCode type questions via Codility