美文网首页
【Leetcode】384. Shuffle an Array

【Leetcode】384. Shuffle an Array

作者: 云端漫步_b5aa | 来源:发表于2020-04-06 13:56 被阅读0次

自己想复杂了,用一个dictionary存储了所有的permutation,然后shuffle的时候直接产生一个随机数,返回任意一个permutation。

看别人的解答才知道,就产生一个random number,swap一下就ok了

相关文章

网友评论

      本文标题:【Leetcode】384. Shuffle an Array

      本文链接:https://www.haomeiwen.com/subject/nixbphtx.html