MCPcopy Create free account
hub / github.com/arnauddri/algorithms / iterativeCount

Function iterativeCount

algorithms/maths/permutations-count/permutations.go:46–58  ·  view source on GitHub ↗
(array []int)

Source from the content-addressed store, hash-verified

44}
45
46func iterativeCount(array []int) int {
47 n := len(array)
48 count := 0
49
50 for i := 0; i < n; i++ {
51 for j := i + 1; j < n; j++ {
52 if array[j] < array[i] {
53 count++
54 }
55 }
56 }
57 return count
58}

Callers 2

TestIterativeFunction · 0.85
BenchmarkIterativeFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestIterativeFunction · 0.68
BenchmarkIterativeFunction · 0.68