Solutions for Count the Triplets

    • @MatthewIdete
    • @alexander, submitted in Python 3, achived 100% score
    from collections import defaultdict 
    def solve(arr):
        n=len(arr)
        p=defaultdict(lambda :0)
        for i in range(len(arr)):
            p[arr[i]]+=1
        c=0
        for i in range(len(arr)):
            for j in range(i+1,len(arr)):
                if((arr[i]+arr[j]) in p):
                    c+=1
        return c