Hi, I wonder if there is 'an operation' that allow me to compute this special function faster than square-time $O(n^2)$.

Assume we have functions $f(x)$ and $h(x)$. $h(x)$ has a special point (maximum) which we are moving through the $f(x)$ and compute maximum. It's a little hard to explain so here is a photo:

My function that I want is this green one after finish process described above.