import (
"fmt"
"github.com/chasestarr/inversion"
)
func main() {
count := inversion.Count([]int{6, 5, 4, 3, 2, 1})
fmt.Println(count) // 15
// # of inversions in reversed array are: (n(n-1))/2
}
chasestarr/inversion
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Inversion.Count returns the number of inversions in an integer array
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published