Python does it for you in single line


#1
from itertools import permutations
class Solution:
    def permute(self, A):
        return list(permutations(A))

#3

Warning : DO NOT USE LIBRARY FUNCTION FOR GENERATING PERMUTATIONS.
Example : next_permutations in C++ / itertools.permutations in python.
If you do, we will disqualify your submission retroactively and give you penalty points.