Simple and short C


  • -3
    D
    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; 
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.