Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. // This is something like n^2 worst-case.
  2. //
  3. // []string must be sorted
  4. func diffStrings(new, old []string) (added, removed []string) {
  5. Add:
  6. for _, x := range new {
  7. for _, y := range old {
  8. if x == y {
  9. continue Add
  10. }
  11. }
  12. added = append(added, x)
  13. }
  14. Rem:
  15. for _, x := range old {
  16. for _, y := range new {
  17. if x == y {
  18. continue Rem
  19. }
  20. }
  21. removed = append(removed, x)
  22. }
  23.  
  24. return added, removed
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement