Print Permutations - String

You are given an input string 'S'. Your task is to find and return all possible permutations of the input string.

Note:
1. The input string may contain the same characters, so there will also be the same permutations.

2. The order of permutation does not matter.
Input Format:
The first and only line of input contains a string 'S' of alphabets in lower case characters.
Output Format:
Print all the permutations of the given string 'S' in a separate line.
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.    
Constraint:
0 <= |S| <= 8

Where |S| denotes the length of string 'S'.

Time limit: 1 sec
CodingNinjas
author
2y

Approach :
We can find all the permutations by Backtracking.

1) Fix a character then swap all the rest of the remaining character with a fixed character.

2) Then find all permutations for all remaining ...read more

CodingNinjas
author
2y
Backtracking

We can find all the permutations by Backtracking.

1: Fix a character then swap all the rest of the remaining character with a fixed character.

2: Then find all permutations for all remainin...read more

Help your peers!
Add answer anonymously...
Virtusa Consulting Services Technology Consultant Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter