$f,g$ continuous from $X$ to $Y$. if they are agree on a dense set $A$ of $X$ then they agree on $X$

Problem:

Suppose $f$ and $g$ are two continuous functions such that $f: X \to Y
$ and $g : X \to Y $. $Y$ is a a Hausdorff space. Suppose $f(x) = g(x)
$ for all $x \in A \subseteq X $ where $A$ is dense in $X$, then $f(x)
= g(x) $ for all $x \in X $.

Attempt at a solution:

Put $h(x) = f – g $. Therefore, $h: X \to Y $ is continuous and $Y$ is Hausdorff by hypothesis. Also we know $h(x) = 0 $ for all $x \in A $ such that $A$ is dense in $X$. I want to show that $h(x)$ vanishes everywhere in $X$. We can show $h(x) = 0 $ for all $x \in X \setminus A $. Suppose $h(x) > 0 $ on $X \setminus A$. Pick points $y_1,y_2 \in Y $. Since $Y$ is Hausdorff, can find open set $O_1, O_2 \subseteq Y $ which are disjoint such that $y_1 \in O_1$ and $y_2 \in O_2$. By continuity, $f^{-1}(O_1), f^{-1}(O_2)$ are open in $X$.

I know that if I can show that one of the $f^{-1}(O_i)$ lies in $X \setminus A $, then we would have a contradiction since we have non-empty open set in $X \setminus A$ and this implies $A$ cannot be dense in $X$. But this is the part I am stuck. Any help would greatly be appreciated.

Also, Would be be possible to prove this without using the Hausdorff condition on $Y$?

Solutions Collecting From Web of "$f,g$ continuous from $X$ to $Y$. if they are agree on a dense set $A$ of $X$ then they agree on $X$"

Suppose $f(x_0) \neq g(x_0)$, then since $Y$ is Hausdorff, there are open sets $U,V \subset Y$ such that
$$
f(x_0) \in U, g(x_0) \in V, \text{ and } U\cap V = \emptyset
$$
Now
$$
x_0\in f^{-1}(U)\cap g^{-1}(V) =: W
$$
and $W$ is open, and hence $\exists a\in A\cap W$, whence
$$
f(a) = g(a) \in U\cap V \Rightarrow U\cap V \neq \emptyset
$$
This contradiction proves the result.

One can do that using nets and prove directly. If $x$ is in the dense set, then clearly $f(x)=g(x)$. Suppose $x$ is outside the dense set, let $x_i$ be a net converging to $x$, whose elements are all from the dense set.

Then $f(x_i)=g(x_i)$ is a net in $Y$. Since $Y$ is Hausdorff we have to have $\lim f(x_i)=\lim g(x_i)$ (recall that being Hausdorff is equivalent to the statement that converging nets have a unique limit point). But now by continuity we finish as the following holds: $$f(x)=f\left(\lim x_i\right)=\lim f(x_i)=\lim g(x_i)=g\left(\lim x_i\right)=g(x).$$