Count triplets less than target
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) -> intExample 1
Input
three_sum_smaller([-2, 0, 1, 3], 2)Output
2