Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktoparrays · meet-in-the-middle · counting
The organizer’s problem statement is available at the official source link.
four sum pairs
Pair sums reduce four choices to two lookups
Group two indices into a left pair sum and the other two into a complementary right pair sum.
| Indices | Pair sums | Match condition |
|---|---|---|
| i < j | S[i] + S[j] | (S[i]+S[j]) + (S[k]+S[l]) = T |
| k < l | S[k] + S[l] | quadruple indices satisfy the statement constraints |
- 1
Build pair sums
Generate valid pair sums for the first two indices. - 2
Find complements
For each pair on the remaining indices, look up the complementary sum. - 3
Count index quadruples
Enforce the task’s distinct-index/order constraints when counting matching quadruples.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 charsRun output
Run your code to see output.