func maximumPrimeDifference(nums []int) int { left := 0 right := len(nums) - 1 for left <= right { if isPrime(nums[left]) { break } left++ } for right >= left { if isPrime(nums[right]) { break } right-- } return right - left }
func isPrime(num int) bool { for i := 2; i*i <= num; i++ { if num%i == 0 { return false } } return num >= 2 }