- 博客(9)
- 收藏
- 关注
原创 算法:快速排序
快速排序的基本原理这里就不详细介绍了,下面给出快排的几种实现方式,以及优化。 单项Partition 对数组分段的时候我们采用从一端开始的方式,下面给出代码 private int partion1Way(int[]a,int start,int end){ int i = start-1; int j = start; int k = a
2018-01-21 15:43:40 140
原创 Leetcode: 149. Max Points on a Line
URL https://leetcode.com/problems/max-points-on-a-line/description/ 描述 Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 解题思路 遍历所有点,计算出每一个点与其他的点的
2018-01-14 23:32:30 158
原创 Leetcode: 164. Maximum Gap
URLhttps://leetcode.com/problems/maximum-gap/description/描述Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.R
2018-01-14 21:49:32 184
原创 leetcode:153. Find Minimum in Rotated Sorted Array
URL https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/description/ 描述: Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2
2018-01-13 21:58:26 259
原创 Leetcode: Find Minimum in Rotated Sorted Array II
URL: https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/description/ 描述: Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affec
2018-01-13 21:53:31 292
原创 jdk代理和cglib代理 demo
关于jdk代理和cglib的概念网络上可以很方便的找到,其之间的区别也解释的很详细,在此我给出这两种代理的简单的应用和注释。下面给出代码。 jdk代理 //接口,使用jd的代理模式,被代理类必须实现一个接口 public interface Hello { void say(); } //目标类(被代理类) public class HelloImpl implements H
2018-01-07 22:11:08 599
原创 算法 : 归并排序
归并排序实现以及空间优化 自顶向下的归并排序 //start 数组的开始位置,end数组结束位置,aux辅助数组 public void mergeSortTop2Bottom(int[]a,int start,int end,int[]aux){ //如果只有一个或者没有元素则直接返回啦 if(start>=end) return; //找到数组中间位置
2018-01-06 16:09:43 210
原创 Leetcode: 148. Sort List
描述:Sort a linked list in O(n log n) time using constant space complexity.URLhttps://leetcode.com/problems/sort-list/description/解释如果时间复杂度是nlogn,则需要使用快速排序或者归并排序的思想,下面给出两种算法代码//归并排序 /** * Definition
2018-01-06 14:15:57 154
原创 Leetcode: 147. Insertion Sort List
描述:Sort a linked list using insertion sort.URLhttps://leetcode.com/problems/insertion-sort-list/description/解释因为我们的链表是单项的,所以每一次是从头节点向后查找要插入的位置,然后当前节点插入指定位置。代码class Solution { public ListNode insert
2018-01-06 14:02:19 165
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人