Question bank › Backtracking
Dsa Backtracking Medium

Permutations with Constraints

Implement a function that generates all permutations of a list of integers, avoiding any permutations that contain consecutive integers in their original order. Input format: - The first line contains an integer N (1 <= N <= 10), the total number of integers in the list. - The second line contains N unique integers separated by spaces. Output format: - Print all valid permutations that do not contain consecutive integers in their original order. Example: Input: 3 1 2 3 Output: [[2, 1, 3], [3, 1, 2], [3, 2, 1]]

Key concepts

backtrackingpermutationconstraint

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.