[...] somebody wrote their own answer, which was also accepted, based purely on other answer, just written in code and giving direct solution [...]
So it is not the same answer. There being an explicit solution is a fairly significant difference. That said, given that it would be very straightforward to change the older answer to include the explicit solution, I'd say suggesting that to its author in a comment would be a slightly better way of dealing with the situation, as it might avoid having two answers around where one would suffice. Note that I say "slightly": posting the answer anyway was, at worst, a sub-optimal approach, and not an egregious mistake. Different circumstances -- say, if larger changes were needed to accommodate the explicit solution, or if the other answer had been posted a while before and its author was not around -- could easily shift the balance.
[...] to get credit with little to no effort.
The second answer does credit the first one (even though it doesn't link to it, which is the optimal way of giving credit to another Stack Overflow post). As for effort, it's neither here nor there: cases of actual plagiarism aside, what matters is what is in the post, not how it was achieved (and, for all we know, the author of the second answer could be perfectly capable of writing an answer as detailed as the first one, had them got there first). The focus should be on making the set of answers to a question as good as possible; anything else is secondary.
I have already found a similar case before, but not to such an extent, which I flagged as not an answer, and it was rejected.
The rejection of that flag was correct. "Not an answer" is for a post that "does not attempt to answer the question", which is clearly not the case here. The answer in discussion here shouldn't be flagged at all. If it were a case of plagiarism -- which, again, it isn't -- a custom mod flag explaining the situation and linking to the other post would be appropriate.