Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- link="https://practice.geeksforgeeks.org/problems/number-of-pairs-1587115620/1#"
- def countPairs(self,a,b,M,N):
- d=[0]*5
- for i in b:
- if i<5:d[i]+=1
- b=sorted(b)
- ans=0
- for i in a:
- if i==0:continue
- elif i==1:ans+=(d[0])
- else:
- idx=bisect.bisect_right(b,i)
- ans+=(len(b)-idx)
- ans+=(d[0]+d[1])
- if i==2:
- ans-=(d[3]+d[4])
- elif i==3 :
- ans+=(d[2])
- return ans
Advertisement
Add Comment
Please, Sign In to add comment