Practice 3Sum With Multiplicity
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Count index triples i < j < k whose values in arr sum to target. Different choices of indices count separately even when their values match. Return the count modulo 10^9 + 7.
Source: 3Sum With Multiplicity on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
arr = [1,1,2,2,3,3,4,4,5,5], target = 8
Output
20
# Example 2
Input
arr = [1,1,2,2,2,2], target = 5
Output
12
# Example 3
Input
arr = [2,1,3], target = 6
Output
1
Constraints
3 <= arr.length <= 3000
0 <= arr[i] <= 100
0 <= target <= 300
Related LeetCode Problems
Practice more problems similar to 3Sum With Multiplicity.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.