Hausdorff dimension of invariant sets for expanding and hyperbolic systems