today Question

Count increasing Subarrays

Difficulty: Easy

Given an array arr[] of integers, count the number of subarrays in arr[] which are strictly increasing with size greater or equal to 2. A subarray is a contiguous part of array. A subarray is strictly increasing if each element is greater then it's previous element if it exists.


Intuition:

Think of this problem like a combo counter in a video game:

Approach:

  1. Initialize:
  2. Loop: Start from the second element (index 1) and go to the end of the array.
  3. Check Condition: Compare the current element arr[i] with the previous element arr[i-1].
  4. Return: The final count.

Solve :

Screenshot 2026-04-11 at 6.28.46 AM.png

Flow Trace

Input: arr = [1, 4, 5, 3, 7]