aboutsummaryrefslogtreecommitdiff
path: root/count_subarr_fixed_bound.py
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-04-26 01:27:38 -0600
committerJack Sangdahl <[email protected]>2025-04-26 01:27:38 -0600
commite005e72b441ae5d8f214adaace18a2312f8be2cf (patch)
treea207c0a2a4b1a0a1f3b142d855301b03e371d127 /count_subarr_fixed_bound.py
parentcb5eca9739f1acc70755952819206e40cd76a078 (diff)
downloadleetcode-e005e72b441ae5d8f214adaace18a2312f8be2cf.tar.gz
leetcode-e005e72b441ae5d8f214adaace18a2312f8be2cf.zip
2444. count subarrays with fixed bounds
Diffstat (limited to 'count_subarr_fixed_bound.py')
-rw-r--r--count_subarr_fixed_bound.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/count_subarr_fixed_bound.py b/count_subarr_fixed_bound.py
index 44fd99c..7409f42 100644
--- a/count_subarr_fixed_bound.py
+++ b/count_subarr_fixed_bound.py
@@ -17,15 +17,15 @@ class Solution(object):
:type maxK: int
:rtype: int
"""
- ans, last_min, last_max, bad = 0, -1, -1, -1
+ ans, prev_min, prev_max, bad = 0, -1, -1, -1
for i, a in enumerate(nums):
if not minK <= a <= maxK:
bad = i
if a == minK:
- last_min = i
+ prev_min = i
if a == maxK:
- last_max = i
- ans += max(0, min(last_min, last_max) - bad)
+ prev_max = i
+ ans += max(0, min(prev_min, prev_max) - bad)
return ans