Like Rich said, there are myriad possible causes, so most of our advice will be worthless.
I only started getting leg cramps when I changed my diet a couple of years ago. I now eat practically zero processed food, only fresh food I cook myself. As a result, I realized that my sodium intake went down to a ridiculously low level. I also noticed that I was most likely to get leg cramps at night after vigorous exercise (like running five miles or more). And it was worse in hot weather, giving further credence to the sodium deficiency hypothesis.
Sodium/potassium/magnesium/whateverium. They're all electrolytes, right?
I had read about the magnesium cure, and also potassium. I tried them both. No help.
So I figured the solution might be as simple as increasing my salt intake. I began doing so by dissolving a quarter to a half teaspoon of salt in a glass of water whenever I needed a drink during the day.
Bingo! That did the trick (at least for me; this is not medical advice). Plus I get the side benefit of having much better tasting water to drink. Win-win! And I hasten to add that my blood pressure readings are still great.
As Rich said, you really should get your own personal situation identified in order to find the right fix. My story, like all the others, is only a random anecdote.