标签:col 就是 else 处理 public 使用 bsp head span
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/ class Solution { public: ListNode* Merge(ListNode* pHead1, ListNode* pHead2){ if((pHead1 == nullptr) && (pHead2 == nullptr)){ return nullptr; } if(pHead1 == nullptr){ return pHead2; } if(pHead2 == nullptr){ return pHead1; } ListNode* dummyhead = new ListNode(-1); ListNode* head = dummyhead; while(pHead1 != nullptr && pHead2 != nullptr){ if(pHead1 -> val < pHead2 -> val){ head -> next = pHead1; pHead1 = pHead1 -> next; } else{ head -> next = pHead2; pHead2 = pHead2 -> next; } head = head -> next; } if(pHead1 != nullptr){ head -> next = pHead1; } if(pHead2 != nullptr){ head -> next = pHead2; } return dummyhead -> next; } };
标签:col 就是 else 处理 public 使用 bsp head span
原文地址:http://www.cnblogs.com/dingxiaoqiang/p/7923010.html