Let $\Omega \subset \mathbb{R}^n$ be a nonempty bounded Lipschitz set and let $g \in W^{1,2}(\Omega)$ be a function such that $Tg \le 0$ almost everywhere, where $T$ is the trace operator.
$a)$ Prove that there exist functions $u \in W_0^{1,2}(\Omega)$ with $u \ge g$ almost everywhere in $\Omega$.
$b)$ Denote by $X$ the set of functions described in $a)$. Prove that $u_{*} \in X$ is a minimizer for $$E[u] = \int_{\Omega}|Du|^2\mathrm{d}x$$ over $X$ if and only if $$\int_{\Omega}Du_{*} \cdot (Dv-Du_{*}) \mathrm{d}x \ge 0,$$ for all $v \in X$.
For part $a)$ the following hint is given: consider first the case $C^0(\overline{\Omega})$. I however can't figure out how to use it.
For part $b)$ I managed to prove the $\Leftarrow$ implication: For any $v \in X$ we have $$\int_{\Omega}Du_{*} Dv \mathrm{d}x \ge \int_{\Omega}|Du_{*}|^2,$$ but we know, by Cauchy-Schwarz, that $$ \left( \int_{\Omega}|Du_{*}|^2 \right)^{1/2} \left( \int_{\Omega}|Dv|^2 \right)^{1/2} \ge \int_{\Omega}Du_{*} Dv \mathrm{d}x.$$ Combining the inequalities and simplifying the resulted inequality, we get $E(v) \ge E(u_{*}),$ for any $v \in X$.
I don't know how to solve the other direction. I just tried to use inequalities like $E[u_{*}+v] \ge E[u_{*}]$, but I didn't get anything.