He left Islaam and then became Muslim again

"...And whoever of you reverts from his religion [to disbelief] and dies while he is a disbeliever - for those, their deeds have become worthless in this world and the Hereafter, and those are the companions of the Fire, they will abide therein eternally."

[Qur'aan Suurah 2 Portion of Verse 217]

 

al-Shaafi'i holds the opinion that if a person apostates from Islaam and then becomes a Muslim again, his deeds will not go to waste. Only if he were to die in the state of an apostate will his deeds go to waste. Maalik, on the other hand, is of the opinion that if a person apostates from Islaam and then becomes a Muslim again, his deeds will have gone to waste. 

 

This difference of opinion becomes evident in regards to a Muslim who performs Hajj, apostates later on, and then becomes a Muslim again. According to al-Shaafi'i his Hajj remains and he does not have to perform it again because his deeds have not gone to waste. According to Maalik, he will have to perform Hajj again because his deeds went to waste because of his apostasy. 

 

Reference(s):

Tafsir al-Qurtubi