Fork me on GitHub
摘要: Swap Nodes in Pairs 两两交换链表中的节点 Given a linked list, swap every two adjacent nodes and return its head. 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表 输入:head = [1,2,3,4 阅读全文
posted @ 2021-03-10 15:23 WilliamCui 阅读(94) 评论(0) 推荐(0)
摘要: Reverse Nodes in k-Group 以K个节点为一组反转链表 Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of 阅读全文
posted @ 2021-03-10 11:40 WilliamCui 阅读(94) 评论(0) 推荐(0)
摘要: Rotate List 旋转链表 Given the head of a linked list, rotate the list to the right by k places. Input: head = [1,2,3,4,5], k = 2 Output: [4,5,1,2,3] 向右旋转 阅读全文
posted @ 2021-03-10 11:33 WilliamCui 阅读(93) 评论(0) 推荐(0)
摘要: Reverse Linked List II 反转链表 Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list 阅读全文
posted @ 2021-03-10 00:18 WilliamCui 阅读(98) 评论(0) 推荐(0)
摘要: Happy Number 快乐数 Write an algorithm to determine if a number n is happy. 判断一个数是否是快乐数 Input: n = 19 Output: true Explanation: 1^2 + 9^2 = 82 8^2 + 2^2 阅读全文
posted @ 2021-03-10 00:07 WilliamCui 阅读(309) 评论(0) 推荐(0)
摘要: Linked List Cycle find cycle begins 环形链表II [返回环的入口节点] 双指针 快慢指针,快指针一次移动2个node,慢指针一次移动1个node, 通过公式推导的结论,当快慢指针在环内相遇到的节点开始继续使用指针依次遍历到环的入口的步数等于从头结点使用指针依次遍历 阅读全文
posted @ 2021-03-10 00:04 WilliamCui 阅读(57) 评论(0) 推荐(0)