Skip to content
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

【126-week1】总结 #59

Open
suncen0505 opened this issue Apr 19, 2019 · 2 comments
Open

【126-week1】总结 #59

suncen0505 opened this issue Apr 19, 2019 · 2 comments

Comments

@suncen0505
Copy link

suncen0505 commented Apr 19, 2019

链表一直都是我的弱项,这次特意去练习了几道链表题,从简单到中等,后续还会有复杂的更新。
链表练习最主要的就是缕清next,next.next的关系,画图最为直观。还有就是一些边界值的设置技巧。

21题解题思路:
技巧一:初始化的时候把head节点初始化一个给定的值,这样,后续操作就不用考虑头节点问题,直接排序好了,把最小的赋值给head.next就可以了。
技巧二:两个链表为空和不为空的判断,循环逻辑依赖判断条件

83题:
刚开始没有注意到排序以后的链表,所以走了弯路。

24题:
交换节点的时候next.next的值比较重要,缕清后会豁然开朗

。。。后续还会有更新

总的解题思路:链表和递归真的很搭

@hapiman
Copy link
Contributor

hapiman commented Apr 19, 2019

dummy.

@yanlingli3799
Copy link
Contributor

特意去看了24题和83题的代码,写的异常简洁,棒。
不过24题的写法,我理解是 new 了个节点(值与 head 值相同)插入链表中,然后把原来的 head 节点给丢掉了,可以考虑下原地逆转怎么做;再延伸一下,如果不是两两逆转,k个一组逆转要怎么做呢?这个方案可能就不适用了哦~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants