Yes, they're good for solving problems with neck pain too. Memory-foam material is considered now as one of the best ones in case of various sleeping stuff so it can be a good decision for you :)
This material became so popular because of its unique ability to adjust to your body position which provides a high level of comfort during sleeping. It's the same in case of pillows https://sleepmentor.net/what-is-the-best-memory-foam-pillow/ , for reducing neck pain and healing illnesesses connected with it, pillows which can adapt to your body pisition are considered as the best ones. Considering that memory-foam pillows can provide a good support for your neck.
Also an other plus for this material is an ability to stay cool during all sleeping time which makes your rest deeper and more comfortable too.
As an alternative to memory-foam pillows the feather ones are often used too but they aren't really good in this case, many doctors don't recommend them because of impossibility for providing enough neck stability.