The point I'm making is that there isn't a correct solution for all input sets. If you can know something about your input set, you can tune your algorithm. If you cannot, then a simple brute force algorithm may be the most maintainable solution. It's a rather generic point. :-)
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?