for (let i = path.at(-1) + 1; i < this.nums.length; i++) { if (Math.abs(this.nums[i] - this.nums[path.at(-1)]) <= this.k) { path.push(i); this.fn(path); path.pop(); } } } } let res;
let nums_size = readInt();
let nums = newArray(); let nums_item; for (let nums_i = 0; nums_i < nums_size; nums_i++) { nums.push(readInt()); } let k = readInt(); let acmSolution = newSolution(); res = acmSolution.maximumSteps(nums, k); print(res);
classSolution { /* Write Code Here */ maximumOccurrences(nums, k) { let maxnum = 1; // nums.sort(); for (let i = 0; i < nums.length; i++) { let curnum = 0; for (let j = 0; j < nums.length; j++) { if (Math.abs(nums[i] - nums[j]) <= k) { curnum++; } } maxnum = Math.max(curnum, maxnum); } return maxnum; } } let res;
let nums_size = readInt();
let nums = newArray(); let nums_item; for (let nums_i = 0; nums_i < nums_size; nums_i++) { nums.push(readInt()); } let k = readInt(); let acmSolution = newSolution(); res = acmSolution.maximumOccurrences(nums, k); print(res);