sort first and brutal search.

```
class Solution {
public:
int threeSumSmaller(vector<int>& nums, int target) {
if(nums.size()<3)return 0;
sort(nums.begin(),nums.end());
int res=0;
for(int i=0;i<nums.size()-2;++i){
if(nums[i]+nums[i+1]+nums[i+2]>=target)break;
for(int j=i+1;j<nums.size()-1;++j){
if(nums[i]+nums[j]+nums[j+1]>=target)break;
for(int k=j+1;k<nums.size();++k){
if(nums[i]+nums[j]+nums[k]>=target){
break;
}else{
res++;
}
}
}
}
return res;
}
};
```