-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2019-07-03:如何反转一个单链表? #89
Comments
把屏幕倒过来。。。 |
牛皮,牛皮,牛皮,三连 |
This comment has been minimized.
This comment has been minimized.
如果没记错的话,大概过程是这样 |
//递归 |
从链表第2个开始,进行排序比较;知道n-1结束;最后将比较过的数据作为一个整体与第一个比较进行比较,进行反转。例如:abcd四个数据; |
入栈出栈 |
双指针,一个指向头,一个指向尾,交换 |
先入栈在出栈 |
思路:定义3个节点分别是preNode, curNode, nextNode. 先将curNode的next赋值给nextNode, 再curNodel的next指向preNode.至此curNode的指针调整完毕。 然后往后移动curNode, 将curNode赋值给preNode,将nextNode赋值给curNode,如此循环到curNode==null为止 代码:
|
可以用头插法,将原来的单链表逆置 |
No description provided.
The text was updated successfully, but these errors were encountered: