Work out the equations for the slope of the LHS on the three intervals, etc.

A posteriori thoughts: because the zeroes of f(x) and g(x) are prescribed, we have 4 free coefficients: the three slopes, and the constant term of h(x).
The slope of the RHS on the three intervals give three equations for the slopes of the unknown function.
This - since the LHS is continuous - determines the graph up to a vertical translation.
The constant term of h(x) allows the final adjustment.