Nielsen interview question

2 pointer based dsa question