Find count of triplets having sum less than or equal to b and subtract count of triplets having sum less than or equal to a - 1.
$ res = countTripletsLessThan ( $ arr , $ n , $ b ) - countTripletsLessThan ( $ arr , $ n , $ a - 1 ) ; return $ res ; }