Skip to content

Commit fd24816

Browse files
committed
Update Max Gap.py
1 parent 9049496 commit fd24816

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

max gap.py Max Gap.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# @Time : 2019/3/14 12:49
33
# @Author : xulzee
44
5-
# @File : max gap.py
5+
# @File : Max Gap.py
66
# @Software: PyCharm
77

88
# 给定一个数组,求如果排序之后,相邻两数的最大差值,要求时
@@ -37,16 +37,18 @@ def maxgap(self, array: list):
3737
res = 0
3838
lastMax = maxs[0]
3939
for k in range(1, array_len):
40-
if hasNum[k]==1:
40+
if hasNum[k] == 1:
4141
res = max(res, mins[k] - lastMax)
4242
lastMax = maxs[k]
4343
return res
4444

4545
def bucket(self, num: int, len: int, min: int, max: int):
46-
return (num - min) * len // (max - min) # 思考
46+
return (num - min) * len // (max - min) # 思考
47+
4748

4849
if __name__ == '__main__':
4950
import random
51+
5052
test = [random.randint(0, 500) for j in range(10)]
5153
print(sorted(test))
52-
print(Solution().maxgap(test))
54+
print(Solution().maxgap(test))

0 commit comments

Comments
 (0)