Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def largestDistance(a)
- array_length = a.length
- x = 0
- y = 2
- largest = 0
- while (x < array_length - 1)
- while (y < array_length - 1)
- if (a[x] - a[y]).abs > largest then
- largest = (a[x] - a[y]).abs
- end
- y = y + 2
- end
- x = x + 2
- y = 2
- end
- x = 1
- y = 3
- while (x < array_length - 1)
- while (y < array_length - 1)
- if (a[x] - a[y]).abs > largest then
- largest = (a[x] - a[y]).abs
- end
- y = y + 2
- end
- x = x + 2
- y = 3
- end
- return largest
- end
Advertisement
Add Comment
Please, Sign In to add comment