Skip to content

Commit a105520

Browse files
committed
Solution as on 04-09-2022 09:20 pm
1 parent ab50a1b commit a105520

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// 2367.✅ Number of Arithmetic Triplets
2+
3+
class Solution
4+
{
5+
public:
6+
int arithmeticTriplets(vector<int> &nums, int diff)
7+
{
8+
int count = 0;
9+
for (int i = 0; i < nums.size(); ++i)
10+
{
11+
for (int j = i + 1; j < nums.size(); ++j)
12+
{
13+
for (int k = j + 1; k < nums.size(); ++k)
14+
{
15+
if (nums[j] - nums[i] == diff && nums[k] - nums[j] == diff)
16+
++count;
17+
}
18+
}
19+
}
20+
return count;
21+
}
22+
};

0 commit comments

Comments
 (0)