func isArraySpecial(nums []int, queries [][]int) []bool { n := len(nums) dp := make([]int, n) flag := nums[0] & 1 pre := 0 for i := 1; i < n; i++ { num := nums[i] if (num & 1) == flag { pre = i } dp[i] = pre flag = num & 1 } ans := make([]bool, len(queries)) for i, query := range queries { if dp[query[1]] <= query[0] { ans[i] = true } } return ans }