Rotate List
来源:互联网 发布:神偷4优化补丁 编辑:程序博客网 时间:2024/05/20 20:02
class Solution {public: ListNode *rotateRight(ListNode *head, int k) { if(head==NULL) return NULL; ListNode *p,*q,*qpre,*end; q=p=head; int count=0; while(p!=NULL) { if(p->next==NULL) end=p; p=p->next; count++; } if(k>=count) k=(k-count)%count; if(count-k==0||k==0) return head; for(int i=1;i<=count-k;i++) { qpre=q; q=q->next; } qpre->next=NULL; end->next=head; return q; }};不停地传,不停地错,写得乱七八糟
0 0
- Rotate List
- Rotate List
- Rotate List
- Rotate List
- Rotate List
- Rotate List
- Rotate List
- Rotate List
- Rotate List
- Rotate List
- Rotate List
- rotate-list
- Rotate List
- Rotate List
- Rotate List
- Rotate List
- Rotate List
- Rotate List
- DELPhI XE5 控件
- 编译bash
- Kruskal算法
- ol和ul列表标签——HTML5一些比较基础的东西
- 张国荣辞世十周年纪念
- Rotate List
- Java 正确的做字符串编码转换
- 使用MySQL命令行修改密码
- 链表插入排序
- emacs配置下coffee环境
- 删除重复记录SQL
- 微软“砸钱”双系统手机 虽不值得称道但也务实
- GIT忽略文件方式
- Rightmost Digit 数论