使用插入排序对链表进行排序。
示例1
输入
{30,20,40}
输出
{20,30,40}
加载中...
import java.util.*; /* * public class ListNode { * int val; * ListNode next = null; * } */ public class Solution { /** * * @param head ListNode类 * @return ListNode类 */ public ListNode insertionSortList (ListNode head) { // write code here } }
/** * struct ListNode { * int val; * struct ListNode *next; * }; */ class Solution { public: /** * * @param head ListNode类 * @return ListNode类 */ ListNode* insertionSortList(ListNode* head) { // write code here } };
# class ListNode: # def __init__(self, x): # self.val = x # self.next = None # # # @param head ListNode类 # @return ListNode类 # class Solution: def insertionSortList(self , head ): # write code here
/* * function ListNode(x){ * this.val = x; * this.next = null; * } */ /** * * @param head ListNode类 * @return ListNode类 */ function insertionSortList( head ) { // write code here } module.exports = { insertionSortList : insertionSortList };
# class ListNode: # def __init__(self, x): # self.val = x # self.next = None # # # @param head ListNode类 # @return ListNode类 # class Solution: def insertionSortList(self , head ): # write code here
package main import . "nc_tools" /* * type ListNode struct{ * Val int * Next *ListNode * } */ /** * * @param head ListNode类 * @return ListNode类 */ func insertionSortList( head *ListNode ) *ListNode { // write code here }
{30,20,40}
{20,30,40}