当前位置:网站首页>Leetcode horloge quotidienne - 61. Liste de chaînes rotatives
Leetcode horloge quotidienne - 61. Liste de chaînes rotatives
2021-10-14 04:19:50 【Sun zhongming】
61. Liste des chaînes rotatives
Difficulté moyenne615
Pour vous donner un noeud d'en - tête de liste head
,Liste des chaînes rotatives,Déplacer chaque noeud de la liste vers la droite k
Position.
Exemple 1:
Entrée:head = [1,2,3,4,5], k = 2
Produits:[4,5,1,2,3]
Exemple 2:
Entrée:head = [0,1,2], k = 4
Produits:[2,0,1]
Conseils:
- Le nombre de noeuds dans la liste de liens est dans la plage
[0, 500]
Intérieur -100 <= Node.val <= 100
0 <= k <= 2 * 109
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * } */
class Solution {
public ListNode rotateRight(ListNode head, int k) {
if(head==null|| k==0){
return head;
}
int len=1;
ListNode tail=head;
ListNode pre=head;
ListNode res=head;
while(tail.next!=null){
tail=tail.next;
len++;
}
tail.next=head;
//Nombre de mouvements de la liste cyclique,BientôtresPointeur déplacé vers la fink%lenDivision
int loop=len-(k%len);
System.out.println(k);
for(int i=0;i<loop;i++){
pre=res;
res=res.next;
}
pre.next=null;
return res;
}
}
版权声明
本文为[Sun zhongming]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/10/20211013211945095S.html
边栏推荐
- Can Laobaigan liquor stock still rise? Is Laobaigan wine worth long-term investment
- How about rely on smart phone stock? Thousands of shares and thousands of comments of rely on smart electronics
- Is Fangda carbon stock worth holding for a long time? Future market trend of Fangda carbon stock
- Can green water source stocks be held for a long time? Why don't blue water stocks rise
- 腦機接口數據分析工具EEGLAB01---安裝eeglab
- 解决:【安全警報】該站點安全證書的吊銷信息不可用,是否繼續?
- Outil d'analyse des données de l'interface cerveau - ordinateur eeglab01 - - - installation eeglab
- Résolution: [alerte de sécurité] l'information sur la révocation du certificat de sécurité de ce site n'est pas disponible. Voulez - vous continuer?
- Aucun protocole TCP disponible dans l'espace tampon ne peut libérer le problème
- Le bon Code est géré - - construire un serveur ci en utilisant Jenkins
猜你喜欢
-
Projet d'équipe (1) (équipe chauve de Jiangshan Dai Youcai)
-
Ruby 's Adventure: 2D Beginner I, Unity Starting
-
17 novembre 2020
-
Will Yonghe Zhikong stock rise? Analysis on stock value of Yonghe intelligent control
-
Is Yingjia gongjiu stock suitable for long-term holding? Thousands of shares and thousands of comments on Yingjia gongjiu stock
-
How about Xingwang Ruijie stock? STARNet Ruijie stock thousands of shares and thousands of comments
-
Why did Tianqi lithium's stock soar recently? Thousands of shares and thousands of comments of Tianqi lithium
-
Can Guangsheng nonferrous metals stock be held for a long time? Guangsheng Nonferrous Metals Co., Ltd
-
How about Yunhai metal stock? Yunhai metal stock thousand shares thousand comments
-
Why doesn't TCL technology stock rise? Reasons for TCL technology stocks falling every day
随机推荐
- What are the good low-cost stocks at present? Potential stocks below 3 yuan
- High quality low price stocks currently at the bottom (list of high quality low price stocks below RMB 10)
- 10 bull stocks with the largest increase in 2021 (demon stocks with a 10 fold increase this year)
- How about Huayin power stock? Will Huayin power stock rise
- Can Luzhou Laojiao stock still be bought? Luzhou Laojiao stock evaluation
- Is Datang Power Generation stock worth holding for a long time? Why does Datang Power Generation stock not rise for ten years
- What does BAIC Blue Valley do? Does BAIC Blue Valley stock have potential
- Principes de la plate - forme de développement Android, questions d'entrevue de développement Android
- Machine level representation of data
- No buffer space available tcp協議無法釋放問題
- 好代碼是管出來的——使用Jenkins搭建CI服務器
- Quelle est la différence entre l'analyse des données et l'exploration des données?
- HTB Jerry
- Detailed explanation of real-time cloud rendering technology - principle, application and advantages
- Original code complement
- Cs8406 cirrus logic up to 192 kHz frame rate
- Générateur de code général de luminosité HD CG
- LeetCode 47. 全排列 II
- 明明很努力的写博客,为啥没人看?试试这些方法和工具(建议收藏)
- 【微信小程序爬虫】表情包小程序图文视频教学,从零写起,保姆教程!!!
- 【微信小程序爬蟲】錶情包小程序圖文視頻教學,從零寫起,保姆教程!!!
- 【 Wechat applet crawler】 emotion Pack applet picture and Text Video Teaching, Write from zero, Nursing tutorial!!!
- Pourquoi personne ne lit un blog?Essayez ces méthodes et outils (Collection recommandée)
- Leetcode 47. Full arrangement II
- Analyse de l'architecture Sonic
- Product power continues to evolve, and the sales volume of Changan Ford increased month on month in September
- More worrying than the safety of power batteries is the shortage of lithium resources
- Jenkins est trop con?Essayez ces alternatives, l'encens voleur!
- Pression artérielle normale (yzoj - 1078)
- Trouver un nombre naturel spécial (yzoj - 1079)
- Nombre de statistiques à 4 chiffres satisfaisant aux conditions (yzoj - 1080)
- Somme des séries (yzoj - 1081)
- Jingjing à rendez - vous (yzoj - 1040)
- Trouver le plus grand diviseur commun des nombres n (yzoj - 1059)
- Imprimer le triangle numérique (yzoj - 1068)
- Mercenaires (yzoj - 1089)
- Calculer la fonction dérivée du polynôme (yzoj - 1090)
- Nombre indépendant de 7 (yzoj - 1091)
- Statistiques (yzoj - 1092)
- Dessiner un rectangle (yzoj - 1093)