from typing import List def isPermutation(L: List[int]) -> bool: """Returns True if L is a permutation of the integers from 0 to len(L)-1.""" return sorted(L) == list(range(len(L))) def testIsPermutation(): print("Testing isPermutation()...", end="") assert isPermutation([0, 2, 1, 4, 3]) == True assert isPermutation([1, 3, 0, 4, 2]) == True assert isPermutation([1, 3, 5, 4, 2]) == False assert isPermutation([1, 4, 0, 4, 2]) == False # Verify that the function is nonmutating: L = [0, 2, 1, 4, 3] isPermutation(L) assert L == [0, 2, 1, 4, 3] print("Passed!") def main(): testIsPermutation() main()