Go doesn't have a generic functionality for filtering slices so we have to do it the old-fashioned way:
https://codeeval.dev/gist/e4e690a79190b67879fe73dbca03eabe
We can do it more efficiently by re-using underlying array of the slice because we know that the result will always be smaller than original slice:
https://codeeval.dev/gist/0bd6cd3d4b2b20e9ebad85009c1a3f80
This avoids allocating a new array for the result. It's also more dangerous.
The original slice a
is now modified but it's not obvious from looking at the code.