Viscosity solutions approach to variational problems