category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

Count of subarrays having sum equal to its length

similar to

Explanation - You need to remember `subarray(i, j) = prefix(i) - prefix(j)` - relation reduced to `prefix(i) - prefix(j) = i - j` - relation reduced to `prefix(i) - i = prefix(j) - j` - count how much similar no.s present, apply `nC2`, as 2 distinct points make a subarray. - **corner case**, count each one individually.