In the title, what I mean by it is that if I have a problem, and I already solve it, and someone posts a good answer (that could answer the question but might not be the solution for me). Can I still accept it? Or should I rather post an answer of my own and accept it myself? I want to give credit to someone with good quality content.
If your solution is the 100% correct, canonical way to answer the question you asked, you should post it and accept it. There is absolutely nothing wrong with answering your own question. In fact: the facilities are provided by the Stack Exchange software to both ask and answer a question at the exact same time!
You can still up vote the other user's answer. It's a nice way to show them that they were helpful, even if they didn't give the perfect solution to the problem. But even that isn't strictly necessary and may need some caution if, in up voting the other user's answer, you end up making it higher voted than the accepted-correct answer. It can cause confusion in that case for future readers.