Describe a necessary and sufficient condition for the spaces $\mathbb R\setminus A$ and $\mathbb R\setminus B$ to be homeomorphic. Let A and B be two finite subsets of $\mathbb R$. Describe a necessary and sufficient condition for the spaces $\mathbb R\setminus A$ and $\mathbb R\setminus B$ to be homeomorphic.
I think $|A|=|B|$. Am I right?
 A: I’m going to assume that you know that all open intervals in $\Bbb R$, including the open rays of the form $(x,\to)$ and $(\leftarrow,x)$, are homeomorphic to one another; if you don’t, you should try to prove it. In what follows I’ll use the term open interval to include the open rays.
If $A$ is finite, then $\Bbb R\setminus A$ is the union of $|A|+1$ open intervals, so it’s homeomorphic to the disjoint union of $|A|+1$ copies of $(0,1)$. Clearly, then, $\Bbb R\setminus A$ is homeomorphic to $\Bbb R\setminus B$ whenever $|A|=|B|$: both are homeomorphic to the disjoint union of $|A|+1$ copies of $(0,1)$.
Suppose that $|A|=m$ and $|B|=n$, where $m<n$. To show that $\Bbb R\setminus A$ and $\Bbb R\setminus B$ are not homeomorphic, you need only show that the disjoint union of $m$ copies of $(0,1)$ is not homeomorphic to the disjoint union of $n$ copies of $(0,1)$. This is true because homeomorphisms, and indeed continuous maps in general, preserve connectedness. Suppose that $h:\Bbb R\setminus A\to\Bbb R\setminus A$ is continuous. Each of the $m$ copies of $(0,1)$ making up $\Bbb R\setminus A$ is a connected subset of $\Bbb R\setminus A$, so $h$ must send it to a connected subset of $\Bbb R\setminus B$. Every connected subset of $\Bbb R\setminus B$ lies entirely within some one of the $n$ copies of $(0,1)$ making up $\Bbb R\setminus B$, so the image of $\Bbb R\setminus A$ under $h$ can fill up at most $m$ of the $n$ copies of $(0,1)$ making up $\Bbb R\setminus B$. Thus, $h$ cannot possibly be a surjection, and $\Bbb R\setminus A$ cannot be homeomorphic to $\Bbb R\setminus B$.
A: Try proving by induction on $n$ that if $A$ is a finite subset of $\mathbb{R}$ with $|A| = n$, then $\mathbb{R} \setminus A$ is homeomorphic to a disjoint union of $n+1$ copies of $\mathbb{R}$.  This suffices.
A: Assume $A=\{a_1, \ldots, a_n\}$ with $a_1<\ldots<a_n$ and $B=\{b_1, \ldots, b_m\}$ with $b_1<\ldots<b_m$.
If $n=m$ we define a homeomorphism  $f:A\to B$ (or vice versa) in the obvious manner:
$$\phi(x)=\begin{cases}x+b_1-a_1 & x<a_1\\\frac{b_{k+1}-b_k}{a_{k+1}-a_k}(x-a_k)+b_k & a_k<x<a_{k+1}, 1\le k<n\\x-b_n-a_n& x>a_n\end{cases}$$
If $n\ne m$, then $\mathbb R\setminus A$ and $\mathbb R\setminus B$ cannot be homeomorphic because we can recover $n$ from $A$ as a topological invariant: It is one less than the number of connected components, i.e. the maximal number of disjoint (relatively) open sets that can cover the whole space. To see this you need to know that each interval is connected, which is not hard.
