break early once value in right surpasses k in left

This commit is contained in:
onyx-and-iris 2024-12-01 18:03:05 +00:00
parent 25b6db75c8
commit 3a10d377ef

View File

@ -34,9 +34,10 @@ func Solve() (int, error) {
var occurrences int
for _, n := range right[indx:] {
if n == k {
occurrences++
if n > k {
break
}
occurrences++
}
similarity += k * v * occurrences
}