Sollicitatievraag bij Connected

Whiteboard question to a code snippet: 1. What the code returns 2. What was the problem with the code 3. How to test it 4. How to optimize it ( there was a nested for loop with was O(n^2) )