I once posted such a question a few months back. In my case, the question was quite specific in terms of describing what I was attempting to do, and in the end I ultimately asked whether my solution (which I posted in the question itself) was "correct", meaning whether it is potentially inefficient, or against a particular best practice (aka "just plain dumb" as I put it).
As Gunr2171 said in the comments, ultimately so long as you avoid questions that are extraordinarily general or broad, you should be ok.
In the case like the one you described in your question, I believe that might qualify as "too broad", since you're not asking a specific question, but rather for users to review your code and comment whether the implementation is correct. You could, hypothetically, rectify that by pointing out a concern you have with your current implementation, and base your question around that (or something along those lines).
I also agree with Bathsheba that the code review SE might also be a good place to post your question. I admit I don't have much experience (other than lurking) on that particular SE site, however from what I can tell, I believe you'd still be required to phrase your question in a specific-enough manner, such as (for example) pointing out a performance concern in your implementation, or something to that effect.
I would disagree with the strategy you mentioned in your answer, however. There is a difference between a "potentially correct answer", and an "actually correct answer", and I would submit that the latter is what belongs in an answer. The former, as the OP, would be perfect as the "here's what I've tried" portion of your question. Admittedly, it is absolutely possible for a user to post a partial answer, but it would really only be acceptable to do so as long as the portion of the question that the partial answer addresses is correct. A solution (even a partial one), that ultimately was wrong would be voted down. In practical terms, you might open yourself up to downvotes on your potential solution (even though its in answer to your own question) if other's see that it is incorrect (assuming it is).