Let $P$ and $Q$ be two non-constant complex polynomials (in one variable). Assume that $$ \{z:\ P(z)=0\} = \{z:\ Q(z)=0\} \text{ and } \{z:\ P(z)=1\} = \{z:\ Q(z)=1\} $$
Then show that $P=Q$.
I tried this: Define a polynomial $R=P-Q$. Now the roots of $R$ include the zeros as well as the ones of $P$ (and Q). If I could show that the set of zeros and ones of $P$ together form a set of degree greater than $P$ then we will be done since then $R$ would be the zero polynomial. But I am not even sure if that is true.
Your original idea works.
I will prove the following
The original question follows from the lemma by considering $P-Q$.
Proof of Lemma: Write $P=c\prod_{i=1}^n(x-z_i)^{r_i}$ and $P-1=c\prod_{j=1}^m(x-w_j)^{s_j}$. We have $$\frac{P'}P=\sum_{i=1}^n\frac{r_i}{x-z_i}$$ and similarly $$\frac{P'}{P-1}=\frac{(P-1)'}{P-1}=\sum_{j=1}^m\frac{s_j}{x-w_j}.$$
Taking the difference, we get: $$\frac{P'}{P(P-1)}=\sum_{j=1}^m\frac{s_j}{x-w_j}-\sum_{i=1}^n\frac{r_i}{x-z_i}.$$
Multiplying both sides by $F=\left(\prod_{i=1}^n(x-z_i)\right)\left(\prod_{j=1}^m(x-w_j)\right)$, we see that the right hand side becomes a polynomial $G$. Therefore we have $FP'= P(P-1)G$, which has degree at least $2d$. Since $P'$ has degree $d-1$, it follows that $n+m=\deg F\geq d+1$.