访问当前节点的时候仅仅需要判断当前节点就可以
struct ListNode { int val; struct ListNode *next; } struct ListNode *a; a = (struct ListNode *)malloc(sizeof(struct ListNode *)); while (a) { a = a->next; }
使用双指针的时候判断下一个节点是否可以访问就可以
struct ListNode *fast,*slow; slow = fast = head; while (fast && fast->next) { fast = fast->next->next; slow = slow->next; }