• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
January 20, 2024 |790 Views
PROBLEM OF THE DAY : 17/01/2024 | All Unique Permutations of an array
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Backtracking but also build up problem-solving skills.

In this problem, we are given an array arr[] of length n. Find all possible unique permutations of the array in sorted order. A sequence A is greater than sequence B if there is an index i for which Aj = Bj for all j<i and Ai > Bi.

Example :

Input: 
n = 3
arr[] = {1, 2, 1}
Output: 
1 1 2
1 2 1
2 1 1

Explanation:
These are the only possible unique permutationsfor the given array.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/all-unique-permutations-of-an-array/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp-compiler/0860475b-24e0-48df-8007-a7ab9efd959a