This question already has an answer here:
Assume $f$ is continuous over $[a,b]$ and $f$ has a local maximum value at every point in $(a,b)$. Show that $f$ is constant.
Intuitively it makes sense that the constant function should be the constant function, but maybe one strategy is to prove that it is a necessary and sufficient condition on $f$. In other words, $f$ is continuous over $[a,b]$ and $f$ has a local maximum value at every point in $(a,b)$ if and only if $f$ is constant. Alternatively we can think of it as such: at every point $A_i$ over $[a,b]$, there exists some interval $J_i$ such that $A_i$ is greater than or equal to every value in of $f$ in $J_i$.
I am unsure which route to take to solve this.