Teradata Interview Question

Solve a hacker rank problem about link list