Leg cramps are common in pregnancy, the elderly, some medical conditions and as exercise/heat cramps. Although they can be due to deficiencies of nutrients such as electrolytes (e.g. magnesium, calcium, sodium and potassium), there is not much evidence to suggest this is true in most cases.
Supplement trials of these nutrients and others (such as carnitine), paint an inconsistent and incomplete picture. The current evidence does not provide clear guidance to clinicians.