πŸ“˜
Placecom Question
  • βœ…ABC? (Contest)
  • βœ…Activity Selection (Contest)
  • βœ…Absolute value discrepancy (Contest)
  • βœ…Akash's Contest (Contest)
  • βœ…Alternate Matrix Addition(Contest)
  • βœ…Anti clockwise(Contest)
  • βœ…Arpit's toy (Contest)
  • βœ…Array Frequency Paradigm (Contest)
  • βœ…Array Games (Contest)
  • βœ…Arranging Students (Contest)
  • βœ…Array Proximity (Contest)
  • βœ…ATM Machine (Contest)
  • βœ…Awesome Numbers(Contest)
  • βœ…Bad Dish (Contest)
  • βœ…Balanced Neighborhood (Contest)
  • βœ…Birthday Gift (Contest)
  • βœ…Boundary Traversal of Matrix(Contest)
  • βœ…Buy and Sell Stock(Contest)
  • βœ…Cakewalk? (Contest)
  • βœ…Can we sort? (Contest)
  • βœ…Candy Love (Contest)
  • βœ…Candy Shopping (Contest)
  • βœ…Choose Card optimally(Contest)
  • βœ…Candy Store Earnings (Contest)
  • βœ…Choose points (Contest)
  • βœ…Concatenate Strings (Contest)
  • βœ…Common digits in two numbers (Contest)
  • βœ…Count 1's in binary array(Contest)
  • βœ…Count Numbers (Contest)
  • βœ…Count Total Digits in a Number (Contest)
  • βœ…Counting Zeroes to Ones (Contest)
  • βœ…Cyclic Rotation Paradigm (Contest)
  • βœ…Derrangement Exercise (Contest)
  • βœ…Diagonal Sum(Contest)
  • βœ…Diet planning (Contest)
  • βœ…Difference Array (Contest)
  • βœ…Digits Rearrangement (Contest)
  • ❌Divisible by 8 (Contest)
  • βœ…Door problem (Contest)
  • βœ…Duplicates at a distance k (Contest)
  • βœ…Easy - Peasy (Contest)
  • βœ…Eat or be Eaten(Contest)
  • βœ…Factorial - Recursion(Contest)
  • βœ…Find element in 2D array (Contest)
  • βœ…Generate all parentheses(Contest)
  • βœ…The gabba test(Contest)
  • βœ…Fruit Market (Contest)
  • βœ…Frequency Sort (Contest)
  • βœ…Floor in a Sorted Array(Contest)
  • βœ…First non-repeating character in a String(Contest)
  • βœ…Find unique(Contest)
  • βœ…Get the Shadow (Contest)
  • βœ…Good cells (Contest)
  • βœ…Good circular array (Contest)
  • βœ…Grid Magic (Contest)
  • βœ…Guardians of Galaxy(Contest)
  • βœ…Happy Balloons (Contest)
  • βœ…Help James (Contest)
  • βœ…Help Samar with Chopsticks (Contest)
  • βœ…Hip Hip Array (Contest)
  • βœ…Increment- Decrement Philosophy (Contest)
  • βœ…Infinity Stones : Form Black Order - The Army of Thanos (Contest)
  • βœ…Insert Operator(Contest)
  • βœ…Integer Modification (contest)
  • βœ…Inversion of array(Contest)
  • βœ…Iso Lexo String (Contest)
  • βœ…Jumping Numbers (Contest)
  • βœ…K closest points(Contest)
  • βœ…Knight game(Contest)
  • βœ…K-Pairs (Contest)
  • βœ…Kth Row of Pascal's Triangle(Contest)
  • βœ…Largest Bitonic Subarray(Contest)
  • βœ…Least Subarrays(Contest)
  • βœ…Lexographical Rotation (Contest)
  • βœ…Lone Sum Supremacy (Contest)
  • βœ…Lucky Boys(Contest)
  • ❌Majority Element(Contest)
  • βœ…Matrix problem(Contest)
  • βœ…Matrix ZigZag Traversal(Contest)
  • βœ…Max Candies(Contest)
  • βœ…Max permute (Contest)
  • βœ…Max Score in Quiz (Contest)
  • βœ…Max sum column (Contest)
  • βœ…Max XOR(Contest)
  • ❌Maximize Strength (Contest)
  • βœ…Maximizing Difference(Contest)
  • βœ…Maximum Area(Contest)
  • ❌Maximizing Difference(Contest)
  • βœ…Maximum Force(Contest)
  • βœ…Longest subarray not having more than K distinct elements(Contest)
  • βœ…Maximum value of difference of a pair of elements and their Index(Contest)
  • βœ…Minimum adjacent difference in a circular array easy(Contest)
  • βœ…Minimum Element in Sorted and Rotated Array(Contest)
  • βœ…Minimum operation - II(Contest)
  • βœ…Missing two(Contest)
  • βœ…Mohit and array(Contest)
  • βœ…Most occurring elements(Contest)
  • βœ…Move Zeros(Contest)
  • βœ…Moving right (Contest)
  • βœ…Max Score in Quiz (Contest)
  • βœ…N integers: Easy (Contest)
  • βœ…Nth node from end of linked list(Contest)
  • βœ…Number of distinct numbers(Contest)
  • βœ…Odd Sum Array (Contest)
  • βœ…Optimal Goodies (Contest)
  • βœ…Orange or Chocolate Candy? (Contest)
  • βœ…Packing Rectangles (Contest)
  • βœ…Pair sum (Contest)
  • βœ…Passcode (Contest)
  • βœ…Permutation - 2 (Contest)
  • βœ…Polynomial equation(Contest)
  • βœ…Power function(Contest)
  • βœ…Power of Three(Contest)
  • βœ…Print Pattern (Contest)
  • βœ…Reduce to 1 (Contest)
  • βœ…Remove Duplicates Inplace(Contest)
  • βœ…Repeating numbers (Contest)
  • βœ…Replace element(Contest)
  • βœ…Ropes (Contest)
  • βœ…Row Index Identification (Contest)
  • βœ…Row with maximum 1's(Contest)
  • βœ…Sara and Monsters (Contest)
  • βœ…Science Camp (contest)
  • βœ…Score bar(Contest)
  • βœ…Search in rotated sorted array(Contest)
  • βœ…Searching an element in a sorted array(Contest)
  • βœ…Separating Negative and Positive numbers(Contest)
  • ❌Sequence Formation (Contest)
  • ❌Setwet's Fish Pond(Contest)
  • βœ…Shopping (Contest)
  • βœ…Simple Circle (Simple Contest)
  • βœ…Simple Pairs(Contest)
  • βœ…Simple Transpose (Contest)
  • βœ…Skit Video (Contest)
  • βœ…Smaller elements (Contest)
  • βœ…Sort it (Contest)
  • βœ…Special digit sum (Contest)
  • βœ…Spiral rotation(Contest)
  • βœ…Squiggly brackets (Contest)
  • βœ…Strange element (Easy-Version)
  • βœ…Subarray with given sum(Contest)
  • βœ…Sum of largest elements(Contest)
  • βœ…Sum Up(Contest)
  • βœ…Swapping Matrix (Contest)
  • βœ…Sweet Bunty (Contest)
  • βœ…Teacher(Contest)
  • βœ…The EndGame : Concatenated Words(Contest)
  • βœ…The high median paradigm (Contest)
  • βœ…Tower of Hanoi(Contest)
  • βœ…Transpose of a matrix(Contest)
  • βœ…Triangular matrix (Contest)
  • βœ…Two Sum Maximization(Contest)
  • βœ…Ultron : Vibranium Quest(Contest)
  • βœ…Wakandan Point in Unsorted Array(Contest)
  • βœ…Yet again Partition sort problem (Contest)
  • βœ…Yet Another Array Rearrangement Problem (Contest)
  • βœ…Zero Padding(Contest)
  • βœ…First & Last (Contest)
  • ❌Fast Search (Contest)
Powered by GitBook
On this page

Permutation - 2 (Contest)

Permutation - 2 easy Time Limit: 2 sec Memory Limit: 128000 kB

PreviousPasscode (Contest)NextPolynomial equation(Contest)

Last updated 2 years ago

Problem Statement :

A ​ permutation is simply a name for a reordering. So the permutations of the string β€˜abc’ are β€˜abc’, β€˜acb’, β€˜bac’, β€˜bca’, β€˜cab’, and β€˜cba’. Note that a sequence is a permutation of itself (the trivial permutation). For this problem, you’ll need to write a ​ recursive​ function ​​ that takes a string and returns a list of all its permutations. A couple of notes on the requirements:

  1. The order of the returned permutations must be lexicographically.

  2. Avoid returning duplicates in your final list. Input Input contains a single string S.

Constraints:- 1<=|S|<=8 Output Print all the permutations of string S in lexicographical order. Example Sample Input: ABC

Sample Output : ABC ACB BAC BCA CAB CBA

Explanation: all permutation are arranged in lexicographical order .

Sample Input: (T(

Sample Output:- ((T (T( T((

link:

```java
import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework

// don't change the name of this class
// you can add inner classes if needed
class Main {
    public static void main (String[] args) {
        // Your code here
        Scanner sc = new Scanner (System.in);
        String s = sc.next();
        Per_two(s,"");
        for(String str:set)
        {
            System.out.print(str+" ");
        }
    }
    public static TreeSet<String>set = new TreeSet<>();
    public static void Per_two(String str, String res){
        if(str.length()==0){
            set.add(res);
            return;
        }
        for(int j=0;j<str.length();j++){
            char a=str.charAt(j);
            String resstr=str.substring(0,j)+str.substring(j+1);
            Per_two(resstr,res+a);
        }
    }
}
```
βœ…
https://my.newtonschool.co/playground/code/sk6syspjk8j3/