Skip to content

Commit 8781478

Browse files
Create Solution.py
1 parent 0a1f663 commit 8781478

File tree

1 file changed

+18
-0
lines changed
  • Medium/2966. Divide Array Into Arrays With Max Difference

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution(object):
2+
def divideArray(self, nums, k):
3+
"""
4+
:type nums: List[int]
5+
:type k: int
6+
:rtype: List[List[int]]
7+
"""
8+
nums.sort()
9+
result = []
10+
11+
for i in range(0,len(nums),3):
12+
group = nums[i:i+3]
13+
if group[-1] - group[0] > k:
14+
return []
15+
result.append(group)
16+
17+
return result
18+

0 commit comments

Comments
 (0)