当前位置:网站首页>The first common node of the two linked lists of "Jianzhi offer"
The first common node of the two linked lists of "Jianzhi offer"
2022-07-27 15:14:00 【A fool is a little proud】
Title Description
Enter two linked lists , Find their first common node .
There are common nodes with the same length , The first time I traverse ;
There are no public nodes , Go to the end NULL meet , return NULLDifferent lengths have common nodes , The difference comes out the first time , Go to the public node together for the second time ;
No public , The second time together to the end NUL
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/ class Solution { public: ListNode* FindFirstCommonNode(ListNode* pHead1, ListNode* pHead2) { ListNode *p1 = pHead1; ListNode *p2 = pHead2; while (p1 != p2){ p1 = (p1 == nullptr ? pHead1 : p1->next); p2 = (p2 == nullptr ? pHead2 : p2->next); } return p1; } };
边栏推荐
- 同花顺开户在手机开户安全吗?
- Txt replace line breaks with spaces or cancel line breaks
- Nefu117 number of prime numbers [prime number theorem]
- DIY制作示波器的超详细教程:(一)我不是为了做一个示波器
- Visual system design example (Halcon WinForm) -10. PLC communication
- 网络设备硬核技术内幕 路由器篇 (10) CISCO ASR9900拆解 (四)
- STM32 can communication filter setting problem
- Sword finger offer merges two sorted linked lists
- adb命令 (安装apk包格式:adb install 电脑上apk地址包名)
- 周鸿祎:数字安全能力落后也会挨打
猜你喜欢

Introduction of the connecting circuit between ad7606 and stm32

积分运算电路的设计方法详细介绍

JMeter recording interface automation
仪表放大器和运算放大器优缺点对比

3.3-5v转换

电子制造行业的数字化转型突破点在哪?精益制造是关键

LeetCode 面试题 17.21. 直方图的水量 双指针,单调栈/hard

Visual system design example (Halcon WinForm) -10. PLC communication

Lecture 4: Longest ascending substring

RS485接口的EMC设计方案
随机推荐
积分运算电路的设计方法详细介绍
Confirm the time accuracy of the power supply setting voltage through the i/o function of vn1630/vn7640
JUC(JMM、Volatile)
TL431-2.5v基准电压芯片几种基本用法
同花顺开户在手机开户安全吗?
LeetCode 191. Number of 1 Bits(位1的个数) 位运算/easy
网络设备硬核技术内幕 路由器篇 16 DPDK及其前传(一)
网络设备硬核技术内幕 路由器篇 10 CISCO ASR9900拆解 (三)
LeetCode 90. 子集 II 回溯/medium
2022-07-27日报:IJCAI 2022杰出论文公布,大陆作者中稿298篇拿下两项第一
CAN总线的EMC设计方案
[work] about technical architecture
什么是Tor?Tor浏览器更新有什么用?
LeetCode 456. 132模式 单调栈/medium
Stm32f103c8t6 drives sh1106 1.3 "IIC OLED display under Arduino frame
Tencent two sides: @bean and @component are used in the same class, what will happen?
IJCAI 2022杰出论文公布,大陆作者中稿298篇拿下两项第一
关于印发《深圳市工业和信息化局绿色制造试点示范管理暂行办法》的通知
NEFU118 n!后面有多少个0【算术基本定理】
网络设备硬核技术内幕 路由器篇 6 汤普金森漫游网络世界(中)