Sorting a string in array, making it sparsely populated.

Posted by S1syphus on Stack Overflow See other posts from Stack Overflow or by S1syphus
Published on 2010-05-24T12:51:03Z Indexed on 2010/05/24 13:11 UTC
Read the original article Hit count: 371

Filed under:
|
|
|

For example, say I have string like:

duck duck duck duck goose goose goose dog 

And I want it to be as sparsely populated as possible, say in this case

duck goose duck goose dog duck goose duck

What sort of algorithm would you recommend? Snippets of code or general pointers would be useful, languages welcome Python, C++ and extra kudos if you have a way to do it in bash.

© Stack Overflow or respective owner

Related posts about c++

Related posts about python