Of the many legal requirements for a Lawful Permanent Resident (LPR) to become a United States Citizen, one is the "continuous residence requirement."
The naturalization process involves filing a petition, having biometrics taken, attending an interview that includes an English and civics/history exam, and an oath ceremony.
The normal rule is that the LPR must have lived in the US continuously for five years immediately preceding the date he or she files the application for naturalization. It is ok if the LPR took trips outside of the US, but he or she must not have been gone for 50% or more of the time.
If the LPR is married to a US citizen, then he or she can be eligible for an exception to the five-year continuous residence requirement and only subject to a three-year continuous residence requirement. If this applies, the LPR must have lived in the US continously for the three years immediately preceding the date he or she files for naturalization. The LPR must be married to a citizen that whole time; and the spouse must have been a citizen for the entire time. Trips outside of the US can't exceed 18 months.
The LPR is no longer eligible to become a citizen under the 3 year rule if, before or after filing the application, the marriage ends because the US Citizen spouse dies or loses their US citizenship, or if a divorce or separation occurs. However, involuntary separation, such as the US citizen serving in the military, will not preclude naturalization.
An LPR man marries a US woman. After three years, the LPR man files an application for naturalization. The couple is married when the LPR has the interview, and he passes. However, prior to the oath ceremony, their divorce becomes final. The LPR man is no longer eligible to take the oath of naturalization. He needs to wait until 2 more years have passed to reapply under the normal rule.
This is only a sliver of the requirements for naturalization. All immigration processes are very complicated, and you should speak to an experienced immigration attorney to verify your eligibility before applying for a benefit.