Re: [閒聊] 每日leetcode

作者: dont   2024-08-16 09:22:01
624. Maximum Distance in Arrays
## 思路
記錄目前遇到的最大最小值
## Code
```python
class Solution:
def maxDistance(self, arrays: List[List[int]]) -> int:
n = len(arrays)
ans = 0
curr_min, curr_max = arrays[0][0], arrays[0][-1]
for i in range(1, n):
ans = max(ans, curr_max - arrays[i][0], arrays[i][-1] - curr_min)
curr_max = max(curr_max, arrays[i][-1])
curr_min = min(curr_min, arrays[i][0])
return ans
```
作者: DJYOMIYAHINA (通通打死)   2024-08-16 09:38:00
我不小心寫了超多redundany 太苦了premium 好久沒寫了*redundancy

Links booklink

Contact Us: admin [ a t ] ucptt.com