首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
转动链表
[编程题]转动链表
热度指数:20266
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32M,其他语言64M
算法知识视频讲解
将给定的链表向右转动k个位置,k是非负数。
例如:
给定1->2->3->4->5->null , k=2,
返回4->5->1->2->3->null。
示例1
输入
{1,2},1
输出
{2,1}
说明:本题目包含复杂数据结构ListNode,
点此查看相关信息
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(48)
分享
提交结果有问题?
0个回答
3篇题解
添加回答
这道题你会答吗?花几分钟告诉大家答案吧!
提交观点
问题信息
链表
难度:
0条回答
48收藏
16369浏览
热门推荐
通过挑战的用户
查看代码
牛客54140...
2022-11-30 11:25:44
=120191...
2022-09-14 17:33:02
牛客61312...
2022-09-12 16:38:43
Varus20...
2022-08-20 16:18:59
牛客97340...
2022-08-10 21:08:27
相关试题
1.该校教师最多的是哪一年?( ...
资料分析
言语理解与表达
资料分析
评论
(1)
你身边有哪些人还没有使用滴滴,你认...
用户研究
评论
(1)
怎么做一个需求
需求分析
评论
(1)
A/B test场景问题,第一类错...
评论
(1)
猿辅导在字节跳动上线一个视频,首页...
评论
(1)
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; /* * public class ListNode { * int val; * ListNode next = null; * } */ public class Solution { /** * * @param head ListNode类 * @param k int整型 * @return ListNode类 */ public ListNode rotateRight (ListNode head, int k) { // write code here } }
/** * struct ListNode { * int val; * struct ListNode *next; * }; */ class Solution { public: /** * * @param head ListNode类 * @param k int整型 * @return ListNode类 */ ListNode* rotateRight(ListNode* head, int k) { // write code here } };
# class ListNode: # def __init__(self, x): # self.val = x # self.next = None # # # @param head ListNode类 # @param k int整型 # @return ListNode类 # class Solution: def rotateRight(self , head , k ): # write code here
/* * function ListNode(x){ * this.val = x; * this.next = null; * } */ /** * * @param head ListNode类 * @param k int整型 * @return ListNode类 */ function rotateRight( head , k ) { // write code here } module.exports = { rotateRight : rotateRight };
# class ListNode: # def __init__(self, x): # self.val = x # self.next = None # # # @param head ListNode类 # @param k int整型 # @return ListNode类 # class Solution: def rotateRight(self , head , k ): # write code here
package main import . "nc_tools" /* * type ListNode struct{ * Val int * Next *ListNode * } */ /** * * @param head ListNode类 * @param k int整型 * @return ListNode类 */ func rotateRight( head *ListNode , k int ) *ListNode { // write code here }
{1,2},1
{2,1}