The question's title already says everything but I will try to elaborate.
Disclaimer: I don't want to unleash the meta effect but I needed an example.
I came across this question with this answer that solved the problem but is very inefficient as I mentioned in my comment.
Is writing an answer to show the best way to solve the problem and leaving a comment on the existing answer as I did enough or what is the best way to handle such situation?
I am asking this because I don't feel that the answer deserves a downvote.
I can't find any possible duplicate so please if this question has been asked provide a link in the comment.