Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Solution {
- public bool ContainsNearbyAlmostDuplicate(int[] nums, int k, int t) {
- if(k==0) return false;
- if(k>nums.Length) return true;
- for(int i=0;i<nums.Length;i++)
- {
- int varK = 1;
- while(varK <= k)
- {
- if(i+varK < nums.Length)
- {
- if((nums[i]-nums[i+varK]) > 0)
- {
- if((nums[i]-nums[i+varK]) <= t)
- return true;
- }
- else if((nums[i+varK]-nums[i]) <= t)
- return true;
- }
- varK++;
- }
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment