package one import "math" func check(nums []int, cmp comparator) bool { for i := 1; i < len(nums); i++ { if cmp(nums, i) || !isSafe(nums[i-1], nums[i]) { return false } } return true } func isSafe(m, n int) bool { return int(math.Abs(float64(m-n))) <= 3 }