aretheythesame.go 313 B

1234567891011121314151617181920212223
  1. package aretheythesame
  2. import "sort"
  3. func Comp(a, b []int) bool {
  4. if a == nil && b != nil || a != nil && b == nil {
  5. return false
  6. }
  7. if len(a) != len(b) {
  8. return false
  9. }
  10. sort.Ints(a)
  11. sort.Ints(b)
  12. for i := 0; i < len(a); i++ {
  13. x := a[i] * a[i]
  14. if x != b[i] {
  15. return false
  16. }
  17. }
  18. return true
  19. }