2 Sum Smaller
(laicode Class99)
Determine the number of pairs of elements in a given array that sum to a value smaller than the given target number.
Assumptions
- The given array is not null and has length of at least 2
Examples
- A = {1, 2, 2, 4, 7}, target = 7, number of pairs is 6({1,2}, {1, 2}, {1, 4}, {2, 2}, {2, 4}, {2, 4})
Analysis:
piazza: https://piazza.com/class/j0eqhhdregb3i?cid=1159
3 sum smaller: https://segmentfault.com/a/1190000003794736