Relative Content

Tag Archive for algorithmsorting

Algorithm for minimizing (s[i]-s[j]+d)/(i-j)

The problem is based on a leetcode contest problem (https://doocs.github.io/leetcode/en/lc/3281/). One can reduce it to following problem: let s be a sorted array and d be an positive integer, minimize (s[i]-s[j]+d)/(i-j). In which i>j.