Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def numberOfArrays(self, differences: List[int], lower: int, upper: int) -> int:
- mx, mn = float("-inf"), float("+inf")
- ps = 0
- for i in differences:
- ps += i
- mx = max(ps, mx)
- mn = min(ps, mn)
- r1 = upper-lower+1
- if mx == mn:
- r2 = abs(mx)
- else:
- r2 = mx - mn
- return max(r1-r2, 0)
Advertisement
Add Comment
Please, Sign In to add comment