Question: I am handling a paper as an associate editor that proposed an algorithm that I find to be weak. In fact, I was able to show that a very simple, brute-force approach actually has a better running time than their algorithm. Therefore, I will recommend rejecting this paper. Do I have an obligation to share my proof that the brute-force running time is better? I want the higher-level editors to have confidence in the rejection, but it also occurs to me that I might be able to improve my own result and publish it independently. Is this a violation of ethics?

UPDATE: Well this certainly took off! I would like to add the following:

* The overwhelming consensus is that it would be unethical for me to "scoop" the other authors, so I will not do that. The advice from all is greatly appreciated.
* The journal is the top in its field, so we have to be extremely selective. The problem proposed is fairly interesting, but overall the paper does not meet our threshold.
* When I say that brute force is better than their method, I mean it in a provable, big O sense.
* The authors' proposed scheme is not only inefficient, it is written in a very confusing way. In fact, I asked them to compare their approach to brute-force as a way of helping them clarify their argument, and they did a bad job of it, which is what led me to look into it in the first place.
* The fact that brute force performs better than their scheme is not totally trivial because it relies on a combinatorial argument that is not amazing, but not completely obvious either.
* I will share my proof with the Editor in chief, but I have decided not to give it to the authors; I will consider publishing independently in the future if their work ever appears elsewhere.
* Their paper is not on arXiv or any other website.

Answer: 
If the paper is overall lousy then simply reject it. I'm sure the reviewers would give you plenty of reasons for this.

However, if all it is, is a weak algorithm but otherwise well written, then it might still be worthy of publication (depends on the journal). Once published, you can then publish your own work and cite the paper. After all, your algorithm is indeed inspired by theirs.

Also, how sure are you that your algorithm is "better"? Always better? 90% of the time better? On CPUs? What about GPUs? How does it scale?

As an example, think about all the sorting algorithms out there. There is not a best algorithm. Depending on the dataset being sorted, any number of algorithms could give the best result.
I believe rejecting a paper just on the basis of poor performance of their algorithm and then publishing your brute force algorithm is highly unethical because: to me it sounds like you tried the idea of making an algorithm only after getting an idea from that work. Secondly, brute force algorithm are not science and they can never win over a smart procedure, it is not ethical to reject a research work to just get yourself a publication. 

Then again, you can very well communicate to the authors that you have something better. Collaborate with them. Tell high level editors you can't handle this with as you are working together with them. That's ethical way to do it.