```
bool containsNearbyAlmostDuplicate(int* nums, int numsSize, int k, int t) {
int i,j,diff;
for (i = 0; i<numsSize; i++) {
for (j = i+1; j<numsSize;j++) {
if (labs(nums[i]-nums[j]) <= t && j-i <=k) return 1;
}
}
return 0;
}
```