I think this method might fail when array contains multiple entries for same value like {1,2,2,2,4,6} and we requires Key=6.
then by following method given in video,
Number of pairs = 1
Original answer, Number of pairs = 3.
What change is needed to correctly solve above case ?