LeetCode Rotate List
来源:互联网 发布:it解决方案 编辑:程序博客网 时间:2024/06/06 18:10
链接: https://oj.leetcode.com/problems/rotate-list/
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */public class Solution{public ListNode rotateRight(ListNode head,int n){int l=0; //链表长度ListNode pos=head;if(pos==null)return pos;while(pos.next!=null){l++;pos=pos.next;}l+=1; pos.next=head; //头节点pos=head;for(int i=0;i<l-n%l-1;i++){ pos=pos.next;} head=pos.next; pos.next=null;return head;}};
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
- 数据加密与解密
- LeetCode----Maximum Depth of Binary Tree
- 汇编编译器伪指令
- NYOJ 527 AC_mm玩dota
- c++封装多线程类
- LeetCode Rotate List
- 详解开源游戏开发框架HaxePunk的主要特性
- Android组件间通信机解耦——Android EventBus和Otto框架
- 【ps】常用快捷键
- HDU5115 Dire Wolf 区间DP 记忆化搜索
- 嵌入式经典面试题-亲身经历
- Redis 命令
- IOS开发---OC语言-㉛OC结构体
- mac os 设置root账户