2393. Count Strictly Increasing Subarrays ¶ Time: $O(n)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6 7 8 9 10 11 12 13 14class Solution { public: long long countSubarrays(vector<int>& nums) { long long ans = 0; for (int i = 0, j = -1; i < nums.size(); ++i) { if (i > 0 && nums[i] <= nums[i - 1]) j = i - 1; ans += i - j; } return ans; } }; 1 2 3 4 5 6 7 8 9 10 11 12 13class Solution { public long countSubarrays(int[] nums) { long ans = 0; for (int i = 0, j = -1; i < nums.length; ++i) { if (i > 0 && nums[i] <= nums[i - 1]) j = i - 1; ans += i - j; } return ans; } } 1 2 3 4 5 6 7 8 9 10 11class Solution: def countSubarrays(self, nums: list[int]) -> int: ans = 0 j = -1 for i, num in enumerate(nums): if i > 0 and num <= nums[i - 1]: j = i - 1 ans += i - j return ans