当前位置:网站首页>[the penultimate node in the linked list]
[the penultimate node in the linked list]
2022-06-22 21:06:00 【Cat star people who love Durian】
List of articles
One 、 Title Description
describe
Enter a linked list , Output the last number in the list k Nodes .
Example 1
Input :1,{1,2,3,4,5}
Return value :{5}
Two 、 Provide easy to read code diagram

3、 ... and 、 Title code
Ideas :fast Go ahead k Step , then slow And fast Let's go together again .fast==NULL when ,slow It's the last k individual
/** * struct ListNode { * int val; * struct ListNode *next; * }; * * C Language declaration defines global variables. Please add static, Prevent duplicate definitions * * C Language declaration defines global variables. Please add static, Prevent duplicate definitions */
/** * * @param pListHead ListNode class * @param k int integer * @return ListNode class */
struct ListNode* FindKthToTail(struct ListNode* pListHead, int k ) {
// write code here
struct ListNode* fast=pListHead;
struct ListNode* slow=pListHead;
while(k--)
{
if(fast==NULL)
return NULL;
fast=fast->next;
}
while(fast)
{
fast=fast->next;
slow=slow->next;
}
return slow;
}
The above is the whole content of this article , If there are mistakes in the article or something you don't understand , Communicate more with meow bloggers . Learn from each other and make progress . If this article helps you , Can give meow bloggers a concern , Your support is my biggest motivation .
边栏推荐
- How to calculate yoy and mom in MySQL
- Flutter System Architecture(Flutter系统架构图)
- Easyclick fixed status log window
- A Dynamic Near-Optimal Algorithm for Online Linear Programming
- The road to systematic construction of geek planet business monitoring and alarm system
- [observation] innovation in the software industry has entered a "new cycle". How can we make a new start in the changing situation?
- 扩展Ribbon支持Nacos权重的三种方式
- R language usarrests dataset visualization
- 迅睿CMS 自定义数据接口-php执行文件代码
- 农产品期货开户
猜你喜欢

阿里云视频点播播放出错,控制台访问出现code:4400

迅睿CMS 自定义数据接口-php执行文件代码

CVPR 2022 oral | video text pre training new SOTA, HKU and Tencent arc lab launched excuse task based on multiple-choice questions

【OR36 链表的回文结构】

Emotion analysis with RNN & CNN pytorch

R语言penguins数据集可视化

【876. 链表的中间结点】

Understand the index of like in MySQL

【142. 环形链表 II】

EasyClick 固定状态日志窗口
随机推荐
How to realize @ person function in IM instant messaging
Scheduling with Testing
性能测试(一)
苹果Objective-C源代码
Can financial products be redeemed on weekends?
R 语言 UniversalBank.csv“ 数据分析
The access succeeds but an exception is thrown: could not find acceptable representation
【OR36 链表的回文结构】
评估指标及代码实现(NDCG)
R language universalbank CSV "data analysis
One picture decoding opencloudos community open day
【CM11 链表分割】
直播预报|中国信息协会网信大讲堂第六期将于6月24日开播啦
慕课6、实现负载均衡-Ribbon
启牛送的券商账户是安全的吗?启牛提供的券商账户是真的?
Ultrafast transformers | redesign vit with res2net idea and dynamic kernel size, surpassing mobilevit
75-当left join遇到子查询
Visualization of R language nutrient dataset
Moke 6. Load balancing ribbon
Flutter System Architecture(Flutter系统架构图)