We have to generate Array (1,2,3,..,n) in O(1) space. I m stuck at how to generate random permutation in O(1) space. I can do it in O(n) space. I did O(n) space solution by first storing the array and then randomizing it in place. But how to do it without storing array in O(1) space.
Aucun commentaire:
Enregistrer un commentaire