One approach would be to use the ZIP-County crosswalk provided by the Department of Housing and Urban Development.
www.huduser.gov/.../usps_crosswalk.html Counties are entirely nested within states, so you could use the crosswalk to match each ZCTA to a set of counties and then check which state those counties belong to. This would give you a mapping between ZCTAs and states.
Here's a list of the relationships between states and counties (each uniquely identified by FIPS codes).
www.census.gov/.../2017-fips.html