MathWorks interview question

eliminate redundancy in linked list - java