Avoid duplicates
This commit is contained in:
parent
b591a6d799
commit
c4de4bceee
4
main.go
4
main.go
|
@ -196,6 +196,10 @@ func InsertWord(arr []word, w word) []word {
|
||||||
return append(arr, w)
|
return append(arr, w)
|
||||||
}
|
}
|
||||||
w2 := arr[len(arr)-1]
|
w2 := arr[len(arr)-1]
|
||||||
|
if w.content == w2.content {
|
||||||
|
// The word is already present
|
||||||
|
return arr
|
||||||
|
}
|
||||||
if w.distance < w2.distance {
|
if w.distance < w2.distance {
|
||||||
return append(arr, w)
|
return append(arr, w)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue