Count the Triplets


The question is about to count the triplets. There is an array of distinct integers given. You have to count the triplets such that the sum of two elements equals the third element.

Write a function solve that have the following parameter(s):
1.) arr = array of integers

Example
Input:
X = [2,4,6,8]
Output:
2

Explanation
The purpose of this function was to count the triplets.
Triplets that can form from an array are:
[2,4,6] = 2+4 = 6
[2,6,8] = 2+6 = 8

Constraints
• Number of elements in the array will be greater than or equal to 1 and less than or equal to 1000.
• The element of the array will be greater than or equal to 1 and less than or equal to 100000.