I've occasionally suffered from leg cramps as well, for me they would occur randomly, usually I'd go for months without any, then get them a few times.
I started taking some potassium tablets at night, which seems to help. There's also some claims it helps with sleep.
I mostly cook my own food from scratch, vs buying packaged/prepared food, so I need to salt it myself. Mixing in some potassium based "no salt" salt in with my table salt might be a good idea as well, to increase daily potassium intake - good idea!