找到两个单链表相交的起始节点。
https://leetcode-cn.com/problems/intersection-of-two-linked-lists/
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//找到两个单链表相交的起始节点。https://leetcode-cn.com/problems/intersection-of-two-linked-lists/description/
typedef struct ListNode{
char val[3];
struct ListNode *next;
}Node;
//方法一:走两遍法
struct ListNode* getIntersectionNode(Node*headA,Node*headB){
struct ListNode* curA = headA;
struct ListNode* curB = headB;
while (curA != curB){
if (curA){
curA = curA->next;
}
else{
curA = headB;
}
if (curB){
curB = curB->next;
}