The units of our final answer $\mathbf t$ are time $[T]$. We'll use $[L]$ to denote units of length. The physical constants involved are
- Acceleration due to gravity $g$ with units of $[L]/[T]^2$, and
- The initial speed $v_0$ with units of $[L]/[T]$.
The idea is to solve for $[T]$ with what we are given, so we can try
$$
\mathbf t = \frac{v_0}{g}\qquad \frac{[L]/[T]}{[L]/[T]^2} = [T]. \tag{1}
$$
Note that we can't be sure this is correct since other functions would also give us the same units, but we can do a little sanity check to make sure this isn't way off the mark. If $v_0\to 0$, so we give it a very weak throw upward, then we expect $\mathbf t(v_0)\to 0$, since of course we are barely tossing the ball! Likewise, if we were on a planet where $g$ was very strong, i.e., $g\to\infty$, then we expect $\mathbf t(g)\to 0$ because we may throw the ball up, but the greater acceleration due to gravity pulls it down very hard. Our initial guess $(1)$ checks out with these two physical ideas.
The actual differential equation to solve is
$$
x''(t) = -g
$$
subject to the initial data
$$
\begin{cases}
x'(0) = v_0, \\
x(0) = 0.
\end{cases}
$$
Here $x(t)$ is the position of the particle at time $t$ and we are throwing the ball from the ground. Thus, the equation of free fall is then $x(t) = v_0t -\frac{1}{2}gt^2$. Setting $x' = 0$ gives us that the time for the ball to reach peak height is $\mathbf t' = v_0/g$. The time to return is double this result, i.e.,
$$\mathbf t = 2\mathbf t' = 2\frac{v_0}{g},$$
so we missed out on the dimensionless factor of $2$.