LeetCode-61-Rotate List 链表水题
来源:互联网 发布:格兰杰詹姆斯数据 编辑:程序博客网 时间:2024/05/01 10:28
# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def rotateRight(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ if head==None:return [] cnt=1 last=head while(last.next!=None): last=last.next cnt+=1 k%=cnt if k==0:return head curHead=head last.next=head print last.val while(cnt>k+1): cnt-=1 curHead=curHead.next ans=curHead.next curHead.next=None return ans
阅读全文
1 0
- LeetCode-61-Rotate List 链表水题
- LeetCode 61: Rotate List
- [leetcode 61] Rotate List
- [leetcode #61]Rotate List
- leetcode || 61、Rotate List
- leetcode[61]:Rotate List
- LeetCode 61: Rotate List
- LeetCode(61) Rotate List
- LeetCode 61 Rotate List
- leetcode 61: Rotate List
- Leetcode#61||Rotate List
- [Leetcode]#61 Rotate List
- leetcode 61:Rotate List
- 【leetcode】【61】Rotate List
- 【LeetCode-61】Rotate List
- LeetCode 61 - Rotate List
- ( Leetcode 61 ) Rotate List
- leetcode-Rotate List-61
- 数据科学中心——首席数据科学家
- 几种常见的排序算法(插入排序,希尔排序,归并排序和快速排序)——希尔排序
- 产品设计师 VS UX设计师:你更想成为哪一个?
- C#连接Oracle服务器(非本地Oracle数据库)
- centos7 安装vsftpd和配置虚拟用户访问及权限分配
- LeetCode-61-Rotate List 链表水题
- ReactNative环信接入
- jquery中prop()方法
- 无向网的深度优先遍历
- 根据枚举类型值获取改值的描述信息
- API Request Get和Post
- Ajax 设置Access-Control-Allow-Origin实现跨域访问
- 10.node+express+mongodb 修改
- js之iframe子页面与父页面通信