Skip to content

Commit

Permalink
optimization: slice sub. (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
FGadvancer authored Jan 10, 2024
1 parent df2a7cc commit fbe872c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions utils/utils_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import (

// SliceSub a中存在,b中不存在 (a-b)
func SliceSub[E comparable](a, b []E) []E {
if len(b) == 0 {
return a
}
k := make(map[E]struct{})
for i := 0; i < len(b); i++ {
k[b[i]] = struct{}{}
Expand Down

0 comments on commit fbe872c

Please sign in to comment.