If you post your question and then realise that you figured out the answer, then you should post a self answer if your question is on-topic for SO. For instance, if the problem was a simple typo, then don't post an answer. Delete your question, as it is likely to be closed and deleted anyways. This is if you make a mistake in posting the question.
If your question is on-topic in accordance with all the help pages, then please do post a self answer. After all, it's more useful information for us, right?
If you do get banned, that means you need to contribute some good answers or good questions.
To quote:
The only way for the ban to be lifted is for you to start contributing positively to the site.
Most likely your post will have no answers (as you deleted it immediately) and there isn't much light shed on the banning system itself (to prevent gaming of the system), so this is just my advice:
Before posting a question, be sure that there are no syntaxical errors in your code.
According to a moderator, it is theoretically possible for them to undelete, upvote, and delete your posts to get you out of a ban, but that would be seen as gaming of the system by many users, even for a good cause, so that's unlikely to happen.
It's hard to get out of a ban. See What can I do when getting "We are no longer accepting answers from this account"? for more detail.
I know you already know this, but for future readers: if you find a grammar mistake or something like that, please edit your question/answer. Don't delete it. We have an edit button for a reason.