Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is something like n^2 worst-case.
- //
- // []string must be sorted
- func diffStrings(new, old []string) (added, removed []string) {
- Add:
- for _, x := range new {
- for _, y := range old {
- if x == y {
- continue Add
- }
- }
- added = append(added, x)
- }
- Rem:
- for _, x := range old {
- for _, y := range new {
- if x == y {
- continue Rem
- }
- }
- removed = append(removed, x)
- }
- return added, removed
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement