Assume $E ⊂ R^n$ as a set in $R^n$ and we have that $x \in E$ and $ y \in R^n \setminus E$. Using the two elements, show the segment $$[x, y] := \{x + t(y − x) : t ∈ [0, 1]\}$$ intersects $\partial E$. Then prove that if $R$ is a rectangle and $x,y \in R$ s.t. $x \in E$ and $ y \in R^n \setminus E$ then $R \cap \partial E \neq \emptyset$.
I am thinking to prove the contrapositive since the function $f:[0,1] \to \Bbb R^n, t \to x + t(y - x)$ is continuous and $[x,y]$, the image of $[0,1]$ by $f$ is connected. So I have to show that if every point of $[x,y]$ is not in the boundary, it would be disconnected.
I have little idea on how to get started so any help or brief outlines would be helpful.
Let $f:[0,1]\to\mathbb R^n$ be the path you defined as $x+(y-x)\cdot t$.
Let $A\subset[0,1]$ be the set $f^{-1}(E)$. Note that $0\in A$, and $A$ has an upper bound in $\mathbb R$, so consider $z=\sup A$. Note that $z\in(0,1)$.
Let $B=\{t\in[0,1]\mid t>z\text{ and }f(t)\notin E\}$. As $1\in B$ and it is a subset of $[0,1]$, $B$ has an infimum. Let $z'=\inf B$. Clearly, $z'\geq z$. If $z'>z$, then consider $z<w<z'$. Since $w\notin B$, $f(w)\in E$, but that implies that $z$ is not the supremum of $A$, a contradiction.
So, $z'=z$. In other words, $\sup A=\inf B$.
I claim that $f(z)\in\partial E=\overline E\cap\overline{\mathbb R^n-E}$. Consider an $\epsilon-$neighborhood $(z-\epsilon,z+\epsilon)\subset[0,1]$ for an arbitrary small $\epsilon >0$. Note that there must be some element $z<u<z+\epsilon$ such that $f(u)\notin E$, since otherwise $z+\epsilon$ would be a lower bound for $B$, a contradiction. And, since $z=\sup A$, there exists some $z-\epsilon<v<z$ such that $f(v)\in E$, since otherwise, $z-\epsilon$ would be an upper bound for $A$, a contradiction.
Since $\epsilon-$neighborhoods are the basis for the standard topology on $\mathbb R$, and the map $f$ is a continuous map, we've shown that $f(z)\in\overline E$ and that $f(z)\in\overline{\mathbb R^n-E}$, so $f(z)\in\partial E=\overline E\cap\overline{\mathbb R^n-E}$.
The remainder of the problem is pretty easy from here, since you know that rectangles are convex (there exists a segment connecting any two points in the shape).