  Nowadays, $f(R)$ theory has been one of the leading modified gravity theories
to explain the current accelerated expansion of the universe, without invoking
dark energy. It is of interest to find the exact cosmological solutions of
$f(R)$ theories. Besides other methods, symmetry has been proved as a powerful
tool to find exact solutions. On the other hand, symmetry might hint the deep
physical structure of a theory, and hence considering symmetry is also well
motivated. As is well known, Noether symmetry has been extensively used in
physics. Recently, the so-called Hojman symmetry was also considered in the
literature. Hojman symmetry directly deals with the equations of motion, rather
than Lagrangian or Hamiltonian, unlike Noether symmetry. In this work, we
consider Hojman symmetry in $f(R)$ theories in both the metric and Palatini
formalisms, and find the corresponding exact cosmological solutions of $f(R)$
theories via Hojman symmetry. There exist some new solutions significantly
different from the ones obtained by using Noether symmetry in $f(R)$ theories.
To our knowledge, they also have not been found previously in the literature.
This work confirms that Hojman symmetry can bring new features to cosmology and
gravity theories.
