最大子数组问题 线性时间
by Franziska Hinkelmann
通过Franziska Hinkelmann
我最喜欢的线性时间排序算法 (My Favorite Linear-time Sorting Algorithm)
盘点排序 (Counting sort with a twist)
The problem: Given an unsorted array of numbers, find the maximum difference between the successive elements in its sorted form. The numbers can be negative or decimals.
问题: 给定一个未排序的数字数组,请以其排序形式找到连续元素之间的最大差值。 数字可以是负数或小数。
简单算法 (Straightforward Algorithm)
const maxGap = input => input .sort((a, b) => a — b) .reduce((acc, cur, idx…
翻译自: https://www.freecodecamp.org/news/my-favorite-linear-time-sorting-algorithm-f82f88b5daa1/
最大子数组问题 线性时间