덱을 랜덤하게 suffle하는 문제입니다. 전에 비슷한 문제를 푼적이 있어 그런식으로 해보았네요.

/** Given an array containing a deck of cards, implement a function that shufflesthe deck.

*Example:var deck = orderedDeck();// [“A♥”,”2♥”,”3♥”,…,”J♦”,”Q♦”,”K♦”]shuffleDeck(deck);// [“2♠”,”J♣”,”A♦”, … ,”7♣”,”8♣”,”K♠”]

*Note:A shuffled deck should be completely random. That means that a given card shouldbe as likely as any other to appear in a given deck index, completely independentof the order of the input deck. Think carefully about how to be sure your algorithmgenerates a properly shuffled deck— it is easy to accidentally create a biased algorithm.

*Extra credit:Even a naive algorithm can easily run in linear time. However, does youralgorithm remain unbiased as N (the deck size) increases? How do you know?Once you have created a properly random, linear algorithm, what is its space complexity?There is an algorithm that uses O(N) time and O(1) space (i.e., an in-place shuffle).

*A further note on randomness:Technically, a c…