Leetcode in Java && Oracle
422 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2022-11-30_23-05-13.png
48.5 KB
#N2367. Number of Arithmetic Triplets
problem link
#solution
class Solution {
public int arithmeticTriplets(int[] nums, int diff) {
int count=0;
Set<Integer> set = new HashSet<>();
for(int n: nums) set.add(n);
for(int i=0; i<nums.length; i++){
if(set.contains(nums[i]+diff) && set.contains(nums[i]+2*diff)) count++;
}
return count;
}
}
3👍1