About counting the number of subsequence (consecutive)

Revision en1, by National_Wind, 2020-12-01 19:10:38

Hi guys, i have this problem. In a given array a length n, how many consecutive subsequence are there that satisfies: max_element — min_element of the subsequence is even. 1 <= n <= 1e5. 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)