Count triplets with sum smaller than X
Given an array arr[] of distinct integers of size N and a value sum, the task is to find the count of triplets (i, j, k), having (i<j<k) with the sum of (arr[i] + arr[j] + arr[k]) smaller than the given value sum.
- Time : O(n^2)
- Space : O(1)
c++
1 | class Solution{ |