Count triplets less than target

Write codeMedium26 min

Your task

Given an array nums and an integer target, count the number of index triples (i, j, k) with i < j < k such that nums[i] + nums[j] + nums[k] < target. Constraints: 0 <= len(nums) <= 3500, -100 <= nums[i] <= 100, -310^4 <= target <= 310^4. Aim for O(n^2).

Examples

three_sum_smaller(nums: list[int], target: int) -> int
Example 1
Inputthree_sum_smaller([-2, 0, 1, 3], 2)
Output2