MathWorks Interview Question

eliminate redundancy in linked list - java