python - I need to calculate the range of the max overlapping occurances not the max number of them -


assume have dataset numbers (start, stop):

4556745  ,  4556749 4556749  ,  5078554 

… , on

i want make chunk of code in order print range (start, stop) in max overlapping occurred. till have managed calculate max number of occurrences not range in in.

my pseudocode – logic :

maxoverlap =  0 currentoverlap = 0 equals 0 j equals 0 m equals len(in_mumbers)  n equals len(out_numbers) while (i less_than m , j less_than n):     if (in_numbers[i] less_than out_numbers[j])         currentoverlap equals currentoverlap + 1         maxoverlap  equals max(maxoverlap, currentoverlap)         equals + 1     else:         currentoverlap equals currentoverlap - 1         j = j + 1   print maxoverlap 

is there idea, suggested readings e.t.c?

the maximum overlapping range maybe (quase surely) not whole tuple (start, stop) of input data.

so i'd transform tuple (start, stop) in range containing range between start , stop:

(4556745,  4556749) → range(4556745, 4556749) 

and i'll process them count occurrence of each number (in dict exemple).

for range in ranges:     number in range:         d.setdefault(num, 0)         d[num]+=1 

then can ever want. max occurring numbers (what call "maximum intersection") , number of intersections concerned, can use get keys maximum value.


Comments

Popular posts from this blog

ssh - Vagrant Windows - ssh_exchange_identification: read: Connection reset by peer -

gcc - Neither ld wrap nor LD_PRELOAD working to intercept system call -

android - How to determine if a in-app subscription on Google Play has been renewed? -