Refactored LinkedList partition method to use filter and reject.