题目
输入两个递增排序的链表, 合并这两个链表并使新链表中的结点仍然是依照递增排序的.
ListNode* Merge(ListNode* pHead1, ListNode* pHead2)
{
if (pHead1 == NULL)
return pHead2;
else if (pHead2 == NULL)
return pHead1;
ListNode* MergeHead = NULL;
if (pHead1->m_nValue < pHead2->m_nValue)
{
MergeHead = pHead1;
MergeHead->m_pNext = Merge(pHead1->m_pNext, pHead2);
}
else
{
MergeHead = pHead2;
MergeHead->m_pNext = Merge(pHead1, pHead2->m_pNext);
}
return MergeHead;
}