  We derive various sharp upper bounds for the $p$-capacity of a smooth compact
set $K$ in the hyperbolic space $\mathbb{H}^n$ and the Euclidean space
$\mathbb{R}^n$. Firstly, using the inverse mean curvature flow, for the mean
convex and star-shaped set $K$ in $\mathbb{H}^n$, we obtain sharp upper bounds
for the $p$-capacity $\mathrm{Cap}_p(K)$ in three cases: (1) $n\geq 2$ and
$p=2$, (2) $n=2$ and $p\geq 3$, (3) $n=3$ and $1<p\leq 3$; Using the unit-speed
normal flow, we prove a sharp upper bound for $\mathrm{Cap}_p(K)$ of a convex
set $K$ in $\mathbb{H}^n$ for $n\geq 2$ and $p>1$. Secondly, for the compact
set $K$ in $\mathbb{R}^3$, using the weak inverse mean curvature flow, we get a
sharp upper bound for the $p$-capacity ($1<p<3$) of the set $K$ with connected
boundary; Using the inverse anisotropic mean curvature flow, we deduce a sharp
upper bound for the anisotropic $p$-capacity ($1<p<3$) of an $F$-mean convex
and star-shaped set $K$ in $\mathbb{R}^3$.
