Tap here to switch tabs
Problem
Submissions

Problem: 3Sum With Multiplicity

3Sum With Multiplicity asks you to count index triples in an integer array whose values add to a target, with each triple using three distinct positions and the result returned modulo a large prime.

Statement

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] is equal to target.

Since the result can be very large, return the answer modulo 109+710^9 + 7.

Constraints:

  • 3≤3 \leq arr.length ≤3000\leq 3000

  • 0≤0 \leq arr[i] ≤100\leq 100

  • 0≤0 \leq target ≤300\leq 300

⋮
Tap here to switch tabs
Problem
Submissions

Problem: 3Sum With Multiplicity

3Sum With Multiplicity asks you to count index triples in an integer array whose values add to a target, with each triple using three distinct positions and the result returned modulo a large prime.

Statement

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] is equal to target.

Since the result can be very large, return the answer modulo 109+710^9 + 7.

Constraints:

  • 3≤3 \leq arr.length ≤3000\leq 3000

  • 0≤0 \leq arr[i] ≤100\leq 100

  • 0≤0 \leq target ≤300\leq 300