public ListNode deleteDuplicates(ListNode head) { ListNode p = head; while (p != null) { ListNode temp = p; while (temp.next != null && temp.val == temp.next.val) { temp.next = temp.next.next; } p = p.next; } return head; }
public ListNode oddEvenList(ListNode head) { if (head == null || head.next == null) { return head; } ListNode odd = head, even = head.next, evenHead = even; while (even != null && even.next != null) { odd.next = even.next; odd = odd.next; even.next = odd.next; even = even.next; } odd.next = evenHead; return head; }