当前位置: > 职场指南 > 面试试题 > 本文内容

程序员面试题精选100题(35)-两链表的第一个公共结点[数据结构] (3)

发布时间:2019-09-22整理:admin阅读:

      ListNode *pFisrtCommonNode = NULL;

      if(pListHeadLong == pListHeadShort)

            pFisrtCommonNode = pListHeadLong;

 

      return pFisrtCommonNode;

}

 

///////////////////////////////////////////////////////////////////////

// Get the length of list with head pHead

// Input: pHead - the head of list

// Return: the length of list

///////////////////////////////////////////////////////////////////////

unsigned int ListLength(ListNode* pHead)

{

      unsigned int nLength = 0;

      ListNode* pNode = pHead;

      while(pNode != NULL)

      {

            ++ nLength;

            pNode = pNode->m_pNext;

      }

 

      return nLength;

}

欢迎分享转载→ 程序员面试题精选100题(35)-两链表的第一个公共结点[数据结构] (3)

相关文章

用户评论

精品推荐

图文资讯

网站地图 - 辞职报告- 职场指南 - 实习总结 - 实习周记 - 实习鉴定- - 个人总结 - 主持词 - 工作计划