[LeetCode] Rotate List
来源:互联网 发布:手机金属探测仪软件 编辑:程序博客网 时间:2024/06/15 19:27
ListNode *rotateRight(ListNode *head, int k) {if(head == NULL){return head;}else if(head->next == NULL){return head;}while(k > 0){ListNode* ptr1 = head;ListNode* ptr2 = ptr1->next;while(ptr2->next != NULL){ptr1 = ptr1->next;ptr2 = ptr2->next;}ptr1->next = NULL;ptr2->next = head;head = ptr2;k--;}return head;}
先实现链表循环右移1位,再将其循环k次,即完成了右移k位
0 0
- [leetcode][list] Rotate List
- LeetCode: Rotate List
- LeetCode Rotate List
- LeetCode : Rotate List
- [Leetcode] Rotate List
- [LeetCode] Rotate List
- [leetcode] Rotate List
- leetcode 70: Rotate List
- [Leetcode] Rotate List
- 【leetcode】Rotate List
- [LeetCode]Rotate List
- [leetcode]Rotate List
- LeetCode-Rotate List
- [leetcode] Rotate List
- LeetCode - Rotate List
- LeetCode:Rotate List
- LeetCode 61: Rotate List
- leetcode之Rotate List
- Hbase + Spring Aop 配置Hbase链接的开启和关闭
- 内存管理--程序在内存中的分布
- [to be]Activiti In Action 翻译计划
- 这是编译器的事情,还是反汇编器的事情
- c语言中assert函数的妙用
- [LeetCode] Rotate List
- asp.net MVC3 中Conroller中对于CRUD的基本操作
- v4l2
- linux关闭firewall,selinux
- 百度质量部 - 开发测试 - 二面
- apidemos ->views/lists/Activate items 学习
- jquery.autocomplete.js 参数属性介绍
- 颜色对照表
- maven报错maven only whitespace content allowed before start tag and not \u0 (position: START_DOCUMENT