Help in this subarray count problem !

Правка en1, от atlasworld, 2019-02-03 15:03:49

Suppose you are given an Array : a[] = { 0 , 0 , 1 , 0 , 0} . size of array can be large upto 2e5. **** You have to count all the subarrays in which a particular element x occurs more than length(subarray) times

for example if x = 0 :

subarrays are :

{0} index = 1 {0} index = 2 {0} index = 4 {0} index = 5

{0,0} index 1 --> 3 {0,0} index 4 -->5 {0,0,1} {0,1,0} {1,0,0} {0,0,1,0} {0,1,0,0} {0,0,1,0,0}

ans = 12.

Any idea !

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский atlasworld 2019-02-03 16:33:55 3 Tiny change: 'subarray) times** \' -> 'subarray) /2 times** \'
en2 Английский atlasworld 2019-02-03 15:04:24 22
en1 Английский atlasworld 2019-02-03 15:03:49 506 Initial revision (published)