Problems with the Question
It's not a bad question. It's not my area of expertise, but I can certainly weigh in on the semantics of the question itself. Here are some of the problems I see (before whatever the current round of edits are):
- It comes off as searchy, which will attract close votes unless you take pains to explain why something isn't searchable.
- It lacks a sufficiency of tags to attract the right set of viewers. Coders will tend to down-vote or close questions that don't have some linkage to programming.
- It lacks information on what you have already considered, other than brute force.
There are a lot of ways to improve this sort of post. I've already tried some edits that may help, but here's a list of how I think this sort of question can usually be improved.
- Problems which are hard to Google for should explain why. For example, in this Ruby answer I note that the OP would have hard a hard time searching for an answer without already knowing the precise terminology.
- Details labels help, especially if they make it clear that it's a language-agnostic algorithms question.
- Describe the use of your algorithm in a way that makes it sound useful and/or practical. This sock-sorting question was contentious largely because it wasn't applicable to any imaginable real-world programming problem.
- Include any algorithms you've considered and why you discarded them. This will reassure people that you've made a valid effort at solving a problem.
- If you're asking about algorithmic complexity, you might want to explain why it matters and why whatever else your doing is not adequate. SO tends to be about pragmatic solutions to real problems; voters tend to punish abstract or purely theoretical questions.
In short, even if your question is on-topic and well-written, it can give off "smells" that attract close-votes and down-votes. Getting out in front of those issues by addressing them in the question itself is often a great way to keep a question that's "risky" from being closed too quickly, but your mileage with this strategy will vary.