Assume that $deg(f)\geq deg(g)$.
$f^{-1}(0)=g^{-1}(0)$ implies that $f(x)$ and $g(x)$ have the same zero set, and it's trivial that $f^{-1}(0)\cap f^{-1}(1)=\emptyset,g^{-1}(0)\cap g^{-1}(1)=\emptyset$.
If we let $h(x)=f(x)-g(x)$ and prove that $|f^{-1}(0)|+|f^{-1}(1)|> deg(f) \geq deg(h)$, then $h(x)\equiv 0$ and $f=g$.(because $h(x)$ has at least $deg(h)+1$ zeros)
Consider
$$f(x)=a(x-x_1)(x-x_2)...(x-x_k)(x-c_1)^{a_1}(x-c_2)^{a_2}...(x-c_m)^{a_m}$$
$a\neq 0$, $x_1,x_2,...,x_k,c_1,c_2,...,c_m$ are all different, $k+\sum_{i=1}^{m}{a_i}=deg(f)$, and notice $|f^{-1}(0)|=k+m$.
Consider $$P(x)=f(x)-1$$
Then we have
$$P'(x)=(\sum_{i=1}^{k}{\frac{f(x)}{x-x_i}})+(\sum_{i=1}^{m}{\frac{a_if(x)}{x-c_i}})$$
And this implies $(x-c_k)^{a_k-1}|P'(x),\forall k=1,2,3,...,m$.
Also, $P(c_k)=-1\neq 0,\forall k=1,2,3,...,m$, and this means $P(x)$ doesn't have any factor like $(x-c_k)$.
Then we have
$$deg(GCD(P,P')) \leq deg(P')-\sum_{i=1}^{m}({a_i-1})=deg(f)-1-(deg(f)-k-m)=k+m-1$$
And
$$|P^{-1}(0)|=deg(P)-deg(GCD(P,P'))\geq deg(f)-(k+m-1)=deg(f)-k-m+1$$
So the number of zeros of $h(x)$ is at least
$$|f^{-1}(0)|+|f^{-1}(1)|=|f^{-1}(0)|+|P^{-1}(0)|\geq k+m+(deg(f)-k-m+1)>deg(f)$$
And this implies
$$|h^{-1}(0)|\geq |f^{-1}(0)|+|f^{-1}(1)| > deg(f)\geq deg(h)\implies h(x) \equiv 0 \implies f=g$$