I look for the solution for the heat-equation with the initial value problem $(\mathbb{I})$: $u(0,x)=f(x)=\begin{cases} B, & \text{if }x\ge 0 \\ A, & \text{if }x<0 \end{cases}$
Now i can't understand, why i just can solve the initial-value problem $(\mathbb{II})$ $u(0,x)=g(x)=\begin{cases} -1, & \text{if }x\ge 0 \\ +1, & \text{if }x<0 \end{cases}$ with solution $u(t,x)$
and then $\frac{1}{2}(A-B)u(t,x) +\frac{1}{2}(A+B)$ solves problem $(\mathbb{I})$?
Let $u$ be the solution of $(\mathbb{II})$ and $$ v(t,x)=\frac{1}{2}\,(A-B)\,u(t,x) +\frac{1}{2}\,(A+B). $$ Then $$ v_t-v_{xx}=\frac{1}{2}\,(A-B)(u_t-u_{xx})=0, $$ so that $v$ is a solution of the heat equation. The initial conditions are $$ v(0,x)=\begin{cases} -\frac{1}{2}\,(A-B)+\frac{1}{2}\,(A+B)=B & \text{if }x\ge 0,\\ \frac{1}{2}\,(A-B)+\frac{1}{2}\,(A+B)=A & \text{if }x<0. \end{cases} $$