algorithms/shuffle
sundowndev e296a1bcc3 add previous solutions 2020-11-18 19:48:31 +01:00
..
readme.md add previous solutions 2020-11-18 19:48:31 +01:00
shuffle.go shuffle function 2020-11-18 19:40:58 +01:00
shuffle_test.go shuffle function 2020-11-18 19:40:58 +01:00

readme.md

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)