[EDIT: Discard strings that have (not that are) prefixes]
- Sort the strings in increasing length order.
- Insert each string into a trie. If the insertion of a character would create a new child node for a currently childless (i.e., leaf) node, discard the current string -- it has a prefix.
[EDIT: Fixed time complexity]
The first step takes O(n log n) time to sort the n strings. If the average string length exceeds log(n), then this time complexity is dominated by the second step, which takes time (and space) linear in the total size of all the input strings. It's pretty easy to implement too.