Weighted lunges and squats. Sounds like cardio isn't your issue, it's muscle exhaustion, so you need to build up your muscle stamina.
Beyond that, make sure that you are stretching plenty before, during and after each hike or workout.
You also might want to try taking a magnesium supplement before your next hike to see if that makes a difference.