About counting the number of subarray

Revision en2, by National_Wind, 2020-12-02 17:02:59

Hi guys, I have this problem. In a given array a length n, how many subarray are there that satisfies: max_element — min_element of the subarray is even. Given that 1 <= n <= 1e5, 1 <= ai <= 1e9. I can't figure out a better solution than O(n^2) solution. How to solve this problem? Thanks!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English National_Wind 2020-12-02 17:02:59 94
en1 English National_Wind 2020-12-01 19:10:38 345 Initial revision (published)