```
class Solution(object):
def threeSumSmaller(self, nums, target):
nums.sort()
i, ans = 0, 0
while i < len(nums) - 2:
left, right = i + 1, len(nums) - 1
while left < right:
tmp = nums[i] + nums[left] + nums[right]
if tmp >= target:
right -= 1
else:
ans += right - left
left += 1
i += 1
return ans
```