My notation: $B(x,\epsilon)=\{y:\| x-y\|<\epsilon\}$
Here's the basic idea:
$(\Rightarrow)$ Assume $f$ is continuous, and let $W\subset\Bbb{R}^n$ be open. Now, let $x\in f^{-1}(W)$; we must find a $\delta$-ball such that $B(x,\delta)\subset f^{-1}(W)$. How? Use the fact that $W$ is open and $f$ is continuous: $f(x)\in W$, $W$ is open so $\exists \epsilon>0$ such that $B(f(x),\epsilon)\subset W$. Can you see how to "find" $\delta$ using continuity?
$(\Leftarrow)$ Suppose $f^{-1}(W)$ is open for every open set $W$, and let $\epsilon>0$. Notice that for every $x\in X$, $B(f(x),\epsilon)$ is an open set. Thus $f^{-1}(B(f(x),\epsilon))$ is an open set in $X$ which contains $x$. Can you see how to find $\delta$ so that $y\in B(x,\delta)\Rightarrow f(y)\in B(f(x),\epsilon)$?