Skip to content

Commit

Permalink
2966. Divide Array Into Arrays With Max Difference
Browse files Browse the repository at this point in the history
  • Loading branch information
BravesDevs committed Feb 1, 2024
1 parent 36b3387 commit d2e6df1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lc/Python/divideArray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution:
def divideArray(self, nums, k):
nums.sort()
res = []
for i in range(0, len(nums), 3):
if nums[i+2]-nums[i] > k:
return []
res.append(nums[i:i+3])
return res


sln = Solution()
print(sln.divideArray([1, 3, 4, 8, 7, 9, 3, 5, 1], 2))

0 comments on commit d2e6df1

Please sign in to comment.