463.Sort Integers-整数排序(入门题)
来源:互联网 发布:搜达数据 编辑:程序博客网 时间:2024/06/08 09:31
删除链表中的元素
题目
删除链表中等于给定值val的所有节点。
样例
给出链表 1->2->3->3->4->5->3, 和 val = 3, 你需要返回删除3之后的链表:1->2->4->5。
题解
1、冒泡法
public class Solution { /** * @param A an integer array * @return void */ public void sortIntegers(int[] A) { for (int i = 0; i < A.length; i++) { for (int j = i+1; j < A.length; j++) { if (A[i] > A[j]) { int tmp = A[j]; A[j] = A[i]; A[i] = tmp; } } } }}
2、插入排序
public class Solution { /** * @param A an integer array * @return void */ public void sortIntegers(int[] A) { for (int i = 1;i < A.length;i++) { int tmp = A[i]; int j = i - 1; for (;j >= 0 && tmp < A[j];j--) { A[j+1] = A[j]; } A[j+1] = tmp; } }}
3、选择排序
public class Solution { /** * @param A an integer array * @return void */ public void sortIntegers(int[] A) { for (int i = 0; i < A.length; i++) { int min = A[i]; int k = i; for (int j = i+1; j < A.length; j++) { if (A[j] < min) { min = A[j]; k = j; } } int tmp = A[k]; A[k] = A[i]; A[i] = tmp; } }}
Last Update 2016.8.11
0 0
- 463.Sort Integers-整数排序(入门题)
- 464.Sort Integers II-整数排序II(容易题)
- 464.Sort Integers II-整数排序 II(容易题)
- [LintCode] Sort Integers 整数排序
- LintCode-463.Sort Integers
- LintCode【入门】整数排序
- lintcode-入门-整数排序
- sort() 排序函数 入门学习
- 入门_463_整数排序(35%)
- #463 Sort Integers
- #464 Sort Integers II
- [LintCode]Sort Integers(C++)
- 排序(Sort)
- 排序函数sort()
- 图解-排序(Sort)
- 图解排序(Sort)
- 排序(Sort)
- 排序(Sort)
- 搭建Spark源码阅读环境
- shadow dom
- JS实现select去除option的使用注意事项
- R语言词云——wordcloud2
- Oracle的SQL语句中如何处理‘&’符号
- 463.Sort Integers-整数排序(入门题)
- Win7环境Python安装BeautifulSoup
- 优化编码习惯,高并发下条件判断范围尽量缩小到需要的地方
- sdut oj2482 二叉排序树
- Deep Convolutional Neural Networks for Microscopy-Based Point of Care Diagnostics 阅读
- Atitit.php nginx页面空白 并返回500的解决
- iOS开发之-收集的不常用却实用的小方法和技巧
- VideoView视频开发
- 清除在使用中的COM口编号