$num) { if (isset($map[$num]) && $key - $map[$num] <= $k) { return true; } $map[$num] = $key; } return false; } }