Internet Brands interview question

Hackerrank challenge