1234567891011121314151617181920212223 |
- package aretheythesame
- import "sort"
- func Comp(a, b []int) bool {
- if a == nil && b != nil || a != nil && b == nil {
- return false
- }
- if len(a) != len(b) {
- return false
- }
- sort.Ints(a)
- sort.Ints(b)
- for i := 0; i < len(a); i++ {
- x := a[i] * a[i]
- if x != b[i] {
- return false
- }
- }
- return true
- }
|