We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
in his solution c+=(min(a[i],b[i])),
here min is acting as min intersection between corresponding elements in count array, means take out the least probablity of intersection.
and add it to variable c.
example: suppose after counting we get the following count array.
a_count=[1,2,0,2]
b_count=[1,2,2,0]
for, i=0 min is 1, so c=1
i=1 min is 2 then c=1+2=3
i=2 min is 0 so c remains same , and so on.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Pairs
You are viewing a single comment's thread. Return to all comments →
in his solution c+=(min(a[i],b[i])), here min is acting as min intersection between corresponding elements in count array, means take out the least probablity of intersection. and add it to variable c. example: suppose after counting we get the following count array. a_count=[1,2,0,2] b_count=[1,2,2,0]
for, i=0 min is 1, so c=1 i=1 min is 2 then c=1+2=3 i=2 min is 0 so c remains same , and so on.