• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
July 21, 2022 |3.3K Views

Java Program to Print all Permutations with Repetition of Characters

  Share   Like
Description
Discussion

In this video, we will Print all Permutations with Repetition of Characters in Java language

What is permutation?
A permutation is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with S itself. It is also known as an arrangement of characters or order, A string of length n has n! permutation. 

1. For an input string of size n, there will be n^n permutations with repetition allowed. 
2. The idea is to fix the first character at the first index and recursively call for the next subsequent indexes. 
3. Once all permutations starting with the first character are printed, fix the second character at the first index. Continue these steps till the last character of a string. 

For example:

Input string: AB 

Output: 
All permutations of AB with repetition are as follows: 
AA 
AB 
BA 
BB 

Print all permutations with Repetition of characters:
https://www.geeksforgeeks.org/print-all-permutations-with-repetition-of-characters/