【LeetCode】147. Insertion Sort List C语言
来源:互联网 发布:怎样注册淘宝买家号 编辑:程序博客网 时间:2024/05/21 07:51
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */struct ListNode* insertionSortList(struct ListNode* head) { if(head == NULL) return head; struct ListNode *dummy= (struct ListNode *)malloc(sizeof(struct ListNode)); dummy->next=NULL; //new start of the sorted list struct ListNode *pre=dummy; //insert node between pre and pre.next struct ListNode *cur=head; //the node will be inserted struct ListNode *Next=NULL; //the next node will be inserted while(cur != NULL) { Next=cur->next; //find the right place to insert while(pre->next != NULL && pre->next->val < cur->val) { pre=pre->next; } //insert between pre and pre.next cur->next=pre->next; pre->next=cur; pre=dummy; cur=Next; } return dummy->next;}
0 0
- 【LeetCode】147. Insertion Sort List C语言
- LeetCode 147. Insertion Sort List
- [LeetCode]147.Insertion Sort List
- [leetcode] 147.Insertion Sort List
- 147. Insertion Sort List LeetCode
- LeetCode 147. Insertion Sort List
- LeetCode *** 147. Insertion Sort List
- Leetcode 147. Insertion Sort List
- leetcode.147. Insertion Sort List
- leetcode 147. Insertion Sort List
- LeetCode-147.Insertion Sort List
- LeetCode - 147. Insertion Sort List
- [leetcode] 147. Insertion Sort List
- [LeetCode] 147. Insertion Sort List
- Leetcode-147. Insertion Sort List
- [LeetCode]147. Insertion Sort List
- LeetCode 147. Insertion Sort List
- 【LeetCode】 147. Insertion Sort List
- effective c++ 条款
- tmk射气球
- Vue2.0 进阶组件篇 5 解析 vux(无逢 marquee 组件)
- Angular2从环境搭建到开发
- IOS 商城首页简单布局
- 【LeetCode】147. Insertion Sort List C语言
- java关于web的一些规范
- Python中四种运行其他程序的方式
- 安卓小事件之点击反应事件
- Android开发之Android5.1.1(CM12.1)源码中短信发送流程解析
- .net 报服务器太忙
- 链队列的基本操作
- Android-线程-简单介绍
- 基于NS-3--NetAnim