Your question is Linked List Duplicate Elements. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Calsoft integration workflows may receive linked lists containing repeated identifiers from upstream processing. Given the head of a singly linked list, return every value that appears more than once, preserving the order in which each duplicate is first identified.
The input is head, a reference to the first ListNode. Each node has an integer val field and a next field containing the next node or None. Return a Python list containing each duplicated value exactly once. If no value appears more than once, return an empty list.
For the examples and test cases, a linked list is represented by an array of node values. The evaluator converts that array into the corresponding ListNode chain before calling the function.
def find_duplicates(head):