algorithms/shuffle/readme.md

425 B

How to shuffle the characters in a string in JavaScript ?

e.g. Given "ABCDEFG", return something like "GEFBDCA".

print(shuffle("the quick brown fox jumps over the lazy dog"));
//-> "veolrm  hth  ke opynug tusbxq ocrad ofeizwj"

print(shuffle("the quick brown fox jumps over the lazy dog"));
//-> "o dt hutpe u iqrxj  yaenbwoolhsvmkcger ozf "
  • Best performance case: O(n)
  • Worst performance case: O(n log n)