摘要: 这道题非常经典,其中快慢指针的思想可以覆盖到很多有链表的题目,值得深刻钻研,我们来看看这道题的原题是什么样的: 也就是说,我们需要找到一个链表当中的中间元素。如果linked list的nodes个数为偶数,则返回中间的那个node,如果linked list的nodes为奇数,则返回第二个中间节点 阅读全文
posted @ 2021-08-25 20:56 Geeksongs 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 题目如下所示: 这个题目我使用字典的方法对其进行了处理,什么意思呢? 就是首先遍历这个链表,然后使用字典统计每一个数字出现的次数,如果出现的次数大于了1次,那么则将其排序后放到我们新创建的链表里,代码如下: # Definition for singly-linked list. # class L 阅读全文
posted @ 2021-08-25 19:53 Geeksongs 阅读(25) 评论(0) 推荐(0) 编辑

Coded by Geeksongs on Linux

All rights reserved, no one is allowed to pirate or use the document for other purposes.