Summary For the LinkList

本文介绍了两种简单有效的链表处理方法:使用向量存储链表元素并通过索引操作,以及采用三个指针(前驱、当前、后继)实现链表的就地反转,附带详细步骤说明。
Keep in mind that there are two ways to deal with the LinkList very easily. 
 
1. Using the vector to store every item of the list, then we can use the index of the vector to operate the link. That helps a lot.
 
2. Using three pointers and should understand the theory.(pre, start, then) 
start is the beginning that we will reverse at the list. 
 
1-2-3-4  pre = 1, start = 2, then = 3
把then 插入到pre的后面,pre不动,then始终在放到start的后面.
start.next = then.next //把then先拿出来
then.next = pre.next //把then在新位置上前后相连
pre.next = then. // then的前面
then = start.next // then  重新放到start的后面  

转载于:https://www.cnblogs.com/zhuguanyu33/p/4423941.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值