The answer I like is, Ukraine defeats the invasion, and Putin gives up, and Ukraine is free.
However, there is an issue to talk about.
While I am not at all expert on Ukraine, as I understand it has been a country divided, with the East wanting to ally with Russia, and the West wanting to align with Western Europe.
If either has 'their' President in office, the other feels occupied by an enemy. It was the case when the revolution happened to remove a Putin puppet, and it was the case when a pro-West leader was in place.
It's always an issue to address regional factions within a country who are at odds with the national leadership. Is it better to let them secede? Better to force them not to? There's an answer 'what's right', that usually isn't as important as 'who can get there way by force'.
In this case, I do consider a possibility, could it be better to let the eastern area that wants to be with Russia, do that, resulting in a unified, pro-west, smaller Ukraine? Preferably with enhanced security agreements against further aggression.
Some might want to argue the historical case of Hitler's 'peace in our time' as he annexed Sudetenland from Czechoslovakia, which was a German speaking area seeming to want to be part of Germany.
The argument could say, 'and look how that went, then he kept on attacking and started the war'. So, Putin could take that, and then keep on attacking and start a war. But he might not.
There's an argument in return, that if he does that, is the time to go to war with him, just as with Hitler. And that it doesn't necessarily mean Sudetenland was wrong. As a practical matter, at least, it's a question to look at. It's terrible in not punishing Putin for the war, which is something the world should try to do regardless IMO. But perhaps this is a better option than not doing it?
Eastern Ukraine's loyalties complicate the issue, making it not as simple as 'Putin seizing part of Ukraine'. I don't have detailed or recent information on how the region feels about becoming part of Russia, and if that's changed, the idea doesn't really apply. But if they still want to be part of Russia, it's something to look at.