From 26c7a5b9bc44cc945524d9d34f2e57799455a1b9 Mon Sep 17 00:00:00 2001 From: Raphael <16480203+sundowndev@users.noreply.github.com> Date: Sat, 14 Sep 2019 15:40:39 +0200 Subject: [PATCH] create javascript/shuffle instructions --- javascript/shuffle/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 javascript/shuffle/README.md diff --git a/javascript/shuffle/README.md b/javascript/shuffle/README.md new file mode 100644 index 0000000..dacee7a --- /dev/null +++ b/javascript/shuffle/README.md @@ -0,0 +1,14 @@ +*How to shuffle the characters in a string in JavaScript ?* + +e.g. Given "ABCDEFG", return something like "GEFBDCA". + +```js +console.log(shuffle("the quick brown fox jumps over the lazy dog")); +//-> "veolrm hth ke opynug tusbxq ocrad ofeizwj" + +console.log(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)