LinkedIn interview question

Hackerrank/Leetcode type question