python3 - using set- no sort - O(MN)
Find the min and max of each subarray, create a set of the subarray, compute the difference between two numbers (difference = (max - min)//(len -1)), check if e
Find the min and max of each subarray, create a set of the subarray, compute the difference between two numbers (difference = (max - min)//(len -1)), check if each number is in the set, worse case time O(len(nums)* len(r)). example : [1, 3, 2, 4, 5], min = 1, max = 5, diff = (5-1)/4, check if each number is in set, starting from min, min + diff, min + diff x 2, min + diff x 3, .... ....\n```\n    def checkArithmeticSubarrays(self, nums: List[int], l: List[int], r: List[int]) -> List[bool]:\n        def isArith(n):\n            mx, mn, st = max(n), min(n), set(n)\n            if (mx - mn)%(len(n)-1) != 0: return False\n            step = (mx - mn)//(len(n)-1)\n            if not step: return mx == mn\n            for i in range(mn, mx, step):\n                if i not in st:\n                    return False\n            return True       \n        res = []\n        for i in range(len(l)):\n            res.append(isArith(nums[l[i]:r[i]+1]))\n        return res\n```\n@10292020 updated based on  ioakeimo\'s suggestion.\n\n```\n    def checkArithmeticSubarrays(self, nums: List[int], l: List[int], r: List[int]) -> List[bool]:\n        def isArith(n):\n            st = set(n)\n            if len(n) != len(st): return len(st) == 1 # take care of duplicates\n            mx, mn, = max(n), min(n)\n            if (mx - mn)%(len(n)-1) != 0: return False\n            step = (mx - mn)//(len(n)-1)\n            for i in range(mn, mx, step):\n                if i not in st:\n                    return False\n            return True   \n        \n        return [isArith(nums[start:stop+1]) for start, stop in zip(l,r)]\n```
[]