Given the level of mathematics I’ve seen involved in hardware, I’d assume the average mech eng. has a better chance than the average software eng.
Mech E. on the other hand, is perhaps the broadest engineering discipline in terms of foundational principles, application variety, and transferable skills. So shouldn't be all that surprising when it comes to hardware engineering.