const fn = (head) => { let curr = head let pre = null while(curr){ const next = curr.next curr.next = pre pre = curr curr = next } return pre }