2018-08-21

2018-08-21  本文已影响9人  常人

遍历数组等要输出元素的个数

使用while循环;

bool isPalindrome(struct ListNode* head)

 { int m =0;

 while(head)

{ head = head ->next ; m++; }

 return result; }

使用while 语句进行对双向链表尾指针进行赋值

while(tmp)

{ length++;

tail = tmp; //store tail value

 tmp = tmp->next; }

链表中的头指针head 只有指针域 没有值域

bool isPalindrome(struct ListNode* head)

*(head -> next).value   才是节点中保存的值 (需要程序的验证);

链表的反转核心思想代码

指针变向等不改变原来内存中的值;

上一篇 下一篇

猜你喜欢

热点阅读