2
def countPairs(self, deliciousness: List[int]) -> int:3
pows = [2**i for i in range(0, 22)] # form our list of powers of 26
) # dict to store what we've seen - dynamic programming solution for time requirement7
count = 0 # to store the answer9
for j in range(0, len(deliciousness)):10
for i in range(0, len(pows)):12
pows[i] - deliciousness[j] in dp_seen13
): # "if we find a previous deliciousness[j] as pows[i] - deliciousness[j], then we will add dp_seen[deliciousness[j]] to count"14
count += dp_seen[pows[i] - deliciousness[j]]15
if deliciousness[j] in dp_seen:16
dp_seen[deliciousness[j]] += 118
dp_seen[deliciousness[j]] = 122
) # the arbitrary modulo, presumably to reduce the answer size