```
int threeSumSmaller(vector<int>& nums, int target) {
sort(nums.begin(), nums.end());
int cnt = 0;
for (int k = 2; k < nums.size(); k++)
for (int i = 0, j = k - 1, t = target - nums[k]; i < j;)
if (nums[i] + nums[j] < t) { cnt += j - i++; }
else { j--;}
return cnt;
}
```