Skip to content

Commit

Permalink
fixed mode count when all numbers are equal
Browse files Browse the repository at this point in the history
  • Loading branch information
kkloberdanz committed Sep 25, 2021
1 parent ec0692f commit 01f1af4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions stc.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func main() {
sort.Slice(allNumbers, func(i, j int) bool {
return allNumbers[i].num < allNumbers[j].num
})
mode = allNumbers[0].num
allNumbersLen := len(allNumbers)
if allNumbersLen%2 == 0 {
a := allNumbers[(allNumbersLen/2)-1].num
Expand Down Expand Up @@ -160,6 +161,9 @@ func main() {
currentCount = 1
}
}
if modeCount == 0 {
modeCount = currentCount
}
}

if *gPtr {
Expand Down

0 comments on commit 01f1af4

Please sign in to comment.