Is it safe to wear a second hand helmet?

I'm a new Rider, and I'm new to the point where I need all the PPE.

Obviously I don't want to break the bank on equipment that doesn't match my skill level. On the other hand I'm reading that helmets need to be replaced every five or so years so is it safe for me to wear a second hand marketplace helmet?

I just want to be safe, and if costs $350 to get a new Shoei then so be it. I just want to believe there's cheaper options that are quality.

Thoughts?