  Consider a centred random walk in dimension one with a positive finite
variance $\sigma^2$, and let $\tau_B$ be the hitting time for a bounded Borel
set $B$ with a non-empty interior. We prove the asymptotic $P_x(\tau_B > n)
\sim \sqrt{2 / \pi} \sigma^{-1} V_B(x) n^{-1/2}$ and provide an explicit
formula for the limit $V_B$ as a function of the initial position $x$ of the
walk. We also give a functional limit theorem for the walk conditioned to avoid
$B$ by the time $n$. As a main application, consider the case that $B$ is an
interval and study the size of the largest gap $G_n$ (maximal spacing) within
the range of the walk by the time $n$. We prove a limit theorem for $G_n$,
which is shown to be of the constant order, and describe its limit
distribution. In addition, we prove an analogous result for the number of
non-visited sites within the range of an integer-valued random walk.
