Documentation ¶
Index ¶
- func MergeTwoLists(l1 *linkedList.ListNode, l2 *linkedList.ListNode) *linkedList.ListNode
- func Partition(head *linkedList.ListNode, x int) *linkedList.ListNode
- func ReorderList(head *linkedList.ListNode) *linkedList.ListNode
- func ReverseList(head *linkedList.ListNode) *linkedList.ListNode
- func ReverseList2(head *linkedList.ListNode, m, n int) *linkedList.ListNode
- func SortList(head *linkedList.ListNode) *linkedList.ListNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MergeTwoLists ¶
func MergeTwoLists(l1 *linkedList.ListNode, l2 *linkedList.ListNode) *linkedList.ListNode
合成两个有序链表
func Partition ¶
func Partition(head *linkedList.ListNode, x int) *linkedList.ListNode
给定一个链表和一个特定值 x,对链表进行分隔,使得所有小于 x 的节点都在大于或等于 x 的节点之前。 https://leetcode-cn.com/problems/partition-list/ 我想的是保存最大结点,小的结点放到前面,官方题解是把大结点保存到另一个链表,最后进行拼接
func ReorderList ¶
func ReorderList(head *linkedList.ListNode) *linkedList.ListNode
https://leetcode-cn.com/problems/reorder-list/ 给定一个单链表 L:L→L→…→L__n→L 将其重新排列后变为: L→L__n→L→L__n→L→L__n→…
func ReverseList ¶
func ReverseList(head *linkedList.ListNode) *linkedList.ListNode
func ReverseList2 ¶
func ReverseList2(head *linkedList.ListNode, m, n int) *linkedList.ListNode
反转从 m开始到n 节点的顺序
func SortList ¶
func SortList(head *linkedList.ListNode) *linkedList.ListNode
给你链表的头结点head ,请将其按升序排列并返回排序后的链表 用mergeSort
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.