Fruits and vegetables contain potassium that may prevent muscle cramps, especially if you’re exercising or outside in hot summer months, says Emily Rubin, RD, registered dietitian in the division of gastroenterology and hepatology at Thomas Jefferson University Hospitals. “One medium banana has 422 mg of potassium.”