Count of triplets

Question

Given an array of unique integers and a sum value, can you write code to find the number of triplets with a sum smaller than the given value?

For example:

#Given the following
Array = [5, 1, 3, 4, 7]
Sum value = 12

#Output: 
4
#Explanation: 
#There are 4 triplets that have a sum less than 12: 
#(1, 3, 4), (1, 3, 5), (1, 3, 7), and (1, 4, 5)

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now