create javascript/shuffle instructions

pull/2/head
Raphael 2019-09-14 15:40:39 +02:00 committed by GitHub
parent 5aef1b4600
commit 26c7a5b9bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -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)