int countTriangles(vector<int>& arr) {
// code here
int count = 0;
sort(arr.begin(), arr.end());
for(int i=2; i<arr.size(); i++) {
int j=0, k=i-1;
while(j<k) {
if(arr[j]+arr[k] > arr[i]) {
count += k-j;
k--;
} else {
j++;
}
}
}
return count;
}