Permutations
Updated
Problem statement
Given an array nums of distinct integers, return every permutation of its values.
For deterministic judging, return the permutations in lexicographic order.
Function
permute(nums: int[]) → List<List<Integer>>Examples
Example 1
nums = [1,2,3]return = [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]Three distinct values have 3! = 6 permutations.
Example 2
nums = [0,1]return = [[0,1],[1,0]]Two values have two possible orders.
Constraints
1 <= nums.length <= 8.- Every value is distinct and in
[-10, 10].
Source note: Author-written prompt excerpt retained for source fidelity.
More EPAM Phone Screen questions
- Longest Palindromic SubstringPHONE SCREEN · Seen Oct 2026
- Container With Most WaterPHONE SCREEN · Seen Oct 2026
- Convert an Entry List to a MapPHONE SCREEN · Seen Oct 2026
- Count Array Element FrequenciesPHONE SCREEN · Seen Oct 2026
- Find First and Last Position of Element in Sorted ArrayPHONE SCREEN · Seen Oct 2026
- Group AnagramsPHONE SCREEN · Seen Oct 2026
- Longest Consecutive SequencePHONE SCREEN · Seen Oct 2026
- Max Consecutive Ones IIIPHONE SCREEN · Seen Oct 2026
- Minimum Currency ConversionsPHONE SCREEN · Seen Oct 2026
- Next Greater Element IPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Combination Sum with Single-Use ValuesPinterest · PHONE SCREENPinterest interview questions
- Combination Sum with Unlimited ReuseNVIDIA · PHONE SCREENNVIDIA interview questions
- Sort by Checking PermutationsMercor · PHONE SCREENMercor interview questions
- Generate All Permutations of a NumberFleetx · ONSITE INTERVIEW
- Bounded Combination Sum with Signed CandidatesConfluent · ONSITE INTERVIEWConfluent interview questions
- Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
- Subsets IIBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Generate Circular Student ArrangementsAmazon · ONSITE INTERVIEW
- Enumerate Compatible Meeting SubsetsExpedia · ONSITE INTERVIEWExpedia interview questions
- Enumerate Valid Clock TimesMicrosoft · OAMicrosoft interview questions