I have difficulty with the following exercise from Introduction to Topology (by Tej Bahadur Singh)(Exercise 9 on p. 36):
Let $f: X\to Y$ be a function between topological spaces, and assume that $A\cup B= X$, where $A-B\subseteq A^\circ$, and $B-A\subseteq B^\circ$. If $f|_{A}$ and $f|_{B}$ (endowed with the relative topologies) are continuous, show that $f$ is continuous.
I tried to use the following facts (from the book mentioned above):
Definition (locally finite). A family $\{A_i\}$ of subsets of a space $X$ is called locally finite if each point of $X$ has a neighborhood $U$ such that $U\cap A_i\neq \varnothing$ for at most finitely many indices $i$.
(1) Let $\{U_\alpha\}$ be a family of open subsets of a space $X$ with $X = \bigcup_\alpha U_\alpha$. Then a function $f$ from $X$ into a space $Y$ is continuous if and only if $f|_{U_\alpha}$ is continuous for each index $\alpha$. (See Exercise 8 on p. 36)
(2) If a space $X$ is the union of a locally finite family $\{A_i\}$ of closed sets, then a function $f$ from $X$ to a space $Y$ is continuous if and only if the restriction of $f$ to each $A_i$ is continuous. (See Corollary 2.1.10 on p. 33)
Using the fact (1), we obtain that $f|_{A^\circ\cup B^\circ}$ is continuous. Clearly, $f|_{A\cap B}$ is continuous. Since $A-B\subseteq A^\circ$ and $B-A\subseteq B^\circ$, $A^\circ \cup B^\circ \cup (A\cap B)= X$. But $A\cap B$ is not open, so I cannot use the fact (1) again, I have not idea what to do next. Any ideas would be appreciated.