算法
sofia嘻嘻
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCodet题解--18. 4Sum(4个数的和)
链接 LeetCode题目:https://leetcode.com/problems/4sum GitHub代码:https://github.com/gatieme/LeetCode/tree/master/018-4Sum 优快云题解:http://blog.youkuaiyun.com/gatieme/article/details/51089460 题意 Given an array S o...转载 2019-03-08 22:05:02 · 141 阅读 · 0 评论 -
十大排序总结
冒泡排序(平均时间复杂度为O(n^2) ,最好情况为顺序 O(n) ,最坏为逆序O(n^2),空间复杂度为O(1) (1)改进后的冒泡排序算法: void BubbleSort2( Sqlist *L) { int i , j; Status flag = true; //用来作标记,当交换时设为true, for(i = 1; i < L->Le...原创 2019-03-19 16:28:50 · 205 阅读 · 0 评论 -
算法的几种重要查找方法
实现折半查找的两种方式 //非递归 public static int binarySearch(int a[], int low, int high, int key){ int l = low, h = high, midst; while(l &lt;= h){ midst = (l + h) / 2; if(key == a[midst]){ return...原创 2019-03-18 11:30:35 · 359 阅读 · 0 评论 -
给定两个-100到100的整数x和y,对x只能加1,减1,乘2操作,问最少对x进行几次操作能得y
java解决算法: import java.util.*; public class A{ public static void main(String[] agrs){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextIn...原创 2019-04-13 18:49:27 · 4323 阅读 · 0 评论
分享