Solve the derivative of g(x)
It is proved that its derivative is greater than or less than 0 in the interval.
We can get that the original function is a increasing function or subtraction function, and then find its values at two endpoints.
Then the rest is simple.