Back to problems

Permutations with Self-Written Tests

Algorithm · SoFi · Easy

Implement a function named permute(nums) that returns every possible ordering of the elements in the input array nums. The initial input consists of distinct values. The output should be a collection of permutations, where each permutation contains the same elements as nums. Use a depth-first search / backtracking approach. You are expected to clarify boundary cases based on a short one-line prompt, and to write your own test methods and test cases. During the interview, you…

Checking your access…