LeetCode 923, Medium. Topics: Array, Hash Table, Two Pointers, Sorting, Counting. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 22 parametrized pytest cases, and a playground notebook:
Problem
Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target.
As the answer can be very large, return it modulo 10^9 + 7.
Examples
Constraints
3 <= arr.length <= 3000
0 <= arr[i] <= 100
0 <= target <= 300
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Last modified on September 7, 2026