Day 6 solution
I'm reasonably happy with this. I started with a bi-directional linked list, but realized that a flat list of all nodes came in handy for one use case while the linked list came in handy for another, so I settled on that.
This commit is contained in:
12
utilities/array.go
Normal file
12
utilities/array.go
Normal file
@ -0,0 +1,12 @@
|
||||
package utilities
|
||||
|
||||
// ArrayContains returns whether the specified array contains the specified value
|
||||
func ArrayContains[T comparable](array []T, val T) bool {
|
||||
for _, v := range array {
|
||||
if v == val {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user