There are a lot of different factors that you should consider, but in the end, it is your decision.
First, the logistical factors you need to consider.
- The answer you select is going to be glued to the top of the answers regardless of the number of votes (except if you select your own answer)
- The check mark is going to stand out for all people who view your question as "This answer is the correct solution". And often these users will have minimal understanding of the situation.
Second (and this is more of my opinion), the aspects of a good answer.
- A correct solution without any explanation is often not helpful to anyone but you, and even then, it might not be helpful to you unless you know what the answer is doing.
- A lot of explanation with no code or code that is not easily understandable, or with a poor quality example can be difficult to implement unless you fully comprehend the description
So in the end, you need to ask yourself:
- If answer #
X did not exist, would I have solved my problem and would I understand the solution as well as I do now.
Whichever answer solves for X is probably the correct answer.