arraycost

package
v0.0.0-...-9c3a112 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package arraycost solves the folowwing problem: given an array B, make up another array A, such that 1<= A[i] <= B[i] and the sum of distances between neighbour elements ( named cost ) is maximised.

Solution: the first element will either be min or maximum and recursively, for the rest of the elements, we calculate two costs: cost when the first element of the remaining ones is min, and when it is max. Then, we conclude the final cost: 1. when the first element is min, we associate it with the second cost 2. when the first element is max, we associate it with either the first or second cost

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cost

func Cost(B []int) int

Cost returns the cost of an array A

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL