If you used an existing answer to come up with a solution the appropriate thing to do is to post an answer with your solution, if you feel that it adds value above and beyond the existing answer. You should certainly upvote the answer that helped you because, well, it helped you.
As for which you mark as the answer, that's your decision and may vary based on the circumstances. For me I would weigh the amount of effort put into the answer that helped me versus what I put in myself. If I spend considerable amount of time and effort, beyond the answer that helped me, then I would just upvote the other answer and mark mine. If the other answer was of high quality, and provided almost all of what I needed and didn't leave too much left for me then I would mark that as the answer, not mine, and consider just commenting on that answer with my changes, rather than posting a new answer.
If you only needed to make minor changes to an answer to your question for it to solve your problem consider commenting on that answer with what you felt it was missing, rather than posting a new answer to add that information.
Note that what you shouldn't do is edit your solution, or the answer you choose, into the question. The question itself should remain a question, and the answer(s) to that question should be in the answers.