It is possible that a person can go to paradise because of a sin and go to the hellfire because of good deeds.
It is possible that a person, he commits a sin and he feels so bad about he feels so guilty about it that he decides to take a U turn in his life.
He repents to Allah and makes a solid determination to change his lifestyle such that he starts to do good deeds. And he continues that pursuit until he breathed his last breath and entered paradise.
And it’s also true that person that the good deeds ends up in hellfire because when they do great deeds, they start to think highly of the souls. Because when they do great deeds, they start to think highly of the souls. They become conceited. And then that leads to pride in the heart. And Allah does not like pride.
And eventually they start to turn away from Allah, both inwardly and outwardly, until they breathe their last breath and let end up in Jahannam.