
algorithm
geeker_leon
这个作者很懒,什么都没留下…
展开
-
Simple sort algorithm
Bubble SortBubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. It can be optimized by stopping the algorithm if inner lo...原创 2019-07-27 22:50:16 · 211 阅读 · 0 评论 -
Linear Sort Algorithm
Bucket SortCreate m empty buckets (Or lists) in order.Split the data into the m bucketsSort each bucket internally using for example: quick sort or merge sortConcatenate all sorted bucketsWith ...原创 2019-07-27 21:51:32 · 336 阅读 · 0 评论 -
LeetCode-数组中的第K个最大元素
题目在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。示例 1:输入: [3,2,1,5,6,4] 和 k = 2输出: 5示例 2:输入: [3,2,3,1,2,4,5,5,6] 和 k = 4输出: 4说明:你可以假设 k 总是有效的,且 1 ≤ k ≤ 数组的长度。https://leetcode...原创 2019-07-26 16:40:34 · 109 阅读 · 0 评论 -
Quick Sort & Merge Sort Algorithm
It is used in Arrays.sort() of Java:One-pivot Quick SortQuick Sort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot. There are m...原创 2019-07-26 10:46:00 · 583 阅读 · 0 评论 -
LeetCode-三数之和
题目给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组。注意:答案中不可以包含重复的三元组。例如, 给定数组 nums = [-1, 0, 1, 2, -1, -4],满足要求的三元组集合为:[[-1, 0, 1],[-1, -1, 2]]https://leetcod...原创 2019-07-25 19:26:04 · 111 阅读 · 0 评论 -
LeetCode-两数之和
题目给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。示例:给定 nums = [2, 7, 11, 15], target = 9因为 nums[0] + nums[1] = 2 + 7 = 9所以返回 [0, 1]https:/...原创 2019-07-25 16:03:27 · 100 阅读 · 0 评论