O(log n) in 1 line Go
Here I implemented my O(log(n) + k) solution in Go, to get rid of the k in the complexity (because due to how Go's slices work, arr[i:i+k] only takes O(1) time)
Here I implemented my [O(log(n) + k) solution](https://discuss.leetcode.com/topic/99281/1-line-o-log-n-k) in Go, to get rid of the k in the complexity (because due to how Go's slices work, `arr[i:i+k]` only takes O(1) time).\n```\nfunc findClosestElements(arr []int, k int, x int) []int {\n\ti := sort.Search(len(arr) - k, func(i int) bool { return x - arr[i] <= arr[i+k] - x })\n\treturn arr[i:i+k]\n}\n```\nOneliner version by slicing twice:\n```\nfunc findClosestElements(arr []int, k int, x int) []int {\n\treturn arr[sort.Search(len(arr) - k, func(i int) bool { return x - arr[i] <= arr[i+k] - x }):][:k]\n}\n```
[]