赞
踩
- //递归
- ListNode* Merge( ListNode* pHead1, ListNoe* pHead2 )
- {
- if ( NULL == pHead1 )
- return pHead2;
- else if ( NULL == pHead2 )
- return pHead1;
-
- ListNode* pMergedHead = NULL;
-
- if ( pHead1->val < pHead2->val ){
- pMergeHead = pHead1;
- pMergeHead->next = Merge( pHead1->next, pHead2 );
- }
- else{
- pMergeHead = pHead2;
- pMergeHead->next = Merge( pHead1, pHead2->next );
- }
-
- return pMergedHead;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。