I think the following is a better way to find faster all the permutations of
a string:

1) sort the string

2) repeat the following:

look for the first i such that from string[i] to string[string.size()-1]
it's not sorted backwards, change string[i] for then next char in
lexicographical order from among the chars in
string[i+1]..string[string.size()-1] and sort that substring (you can do it
in o(n)) that takes o(n!*n). I think yours too but I think this is the
better way to do it fast.

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to google-c...@googlegroups.com.
To unsubscribe from this group, send email to 
google-code+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to