public ListNode swapPairs(ListNode head) {
        ListNode header = new ListNode(0);
        header.next = head;
        
//        assert (head!=null && head.next!=null):"the number of nodes in list < 2";

        if (head==null || head.next==null)
        	return head;
        
        ListNode pre = header;
        ListNode p1 = head;
        ListNode p2 = head.next;
        
        while (p1!=null && p2!=null){
        	ListNode temp = p2.next;
        	pre.next = p2;
        	p2.next = p1;
        	p1.next = temp;
        	pre = p1;      
        	p1 = pre.next;
        	if (p1==null)
        		break;
        	else
        		p2=p1.next;
        }
        
        if(p2==null){
        	pre.next = p1;
        }
        
        return header.next;
    }