class Solution:
def checkArithmeticSubarrays(self, nums: List[int], l: List[int], r: List[int]) -> List[bool]:
result = []
for ll, rr in zip(l, r):
f = True
t = sorted(nums[ll:rr+1])
d = t[1]-t[0]
for i in range(rr-ll):
if t[i+1]-t[i] != d:
f = False
break
result.append(f)
return result
좀 어려운 문제인가? 했는데 생각해보니 별로 안 어려웠다. 힌트 보니까 그냥 소트 쓰라네 뭐하는 문제지..
댓글 0