3254. Number of Divisible Triplet Sums

Medium
Array
Hash Table

Description

Hints

Hint 1
Fix index <code>L</code> to be the leftmost element of a triplet.
Hint 2
Starting from <code>L</code>, go forward and add the remainder of each element to a map.
Hint 3
Now when you are at index <code>R</code>, consider <code>nums[L] + nums[R]</code> and calculate what the remainder of the third element should be.
Hint 4
Then use the map to find the number of valid third elements between <code>L</code> and <code>R</code>.

Statistics

Acceptance
67.4%
Submissions
13,591
Accepted
9,166