It is up to you which answer you accept. The votes on the posts are the feedback of the community, but in the end, it is you who decides which one to accept.
If you hover over the check mark, when it is not highlighted, it says (with emphasis of mine),
Click to accept this answer because it solved your problem or was the most helpful in finding your solution (click again to undo)
As it says, you can accept the answer which either solved your problem or was the most helpful in finding a solution.
From this Meta SE answer,
- Don't hesitate to accept an answer that is well-written, suggests a good practice and works for you.
- Otherwise, even if there are answers that are good enough but that you're not entirely satisfied by, you might wait 24 to 48 hours to give other people a chance to give you a better answer. A question with an accepted answer isn't as likely to receive further attention as one without an accepted answer.
- Make sure that besides working for you, the answer is really good practice. Sometimes after the answer gets accepted, another comes in, uncovering the fact that previous one was in fact a bad hack.
- The bottom line is that you should accept the answer that you found to be the most helpful to you, personally.