`{"id":"132bc873-f130-4568-892f-e233b1301969","name":"Print All Permutations Of A String Iteratively","description":"<p>1. You are given a string. 2. You have to print all permutations of the given string iteratively.</p>","inputFormat":"A String","outputFormat":"All permutations of the given string(one in a line).","constraints":"1 &lt;= length of string &lt;= 15","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<string>\nusing namespace std;\n\n\nvoid printallperm(string str)\n{\n //write your code here\n}\nint main()\n{\n string str;\n getline(cin,str);\n \n printallperm(str);\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void solution(String str){\r\n\t\t// write your code here\r\n\t\t\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString str = scn.next();\r\n\t\tsolution(str);\r\n\t}\r\n\r\n}"},"python":{"code":"def printallperm(st):\n #write your code here\n\nst=input()\nprintallperm(st)"}},"points":10,"difficulty":"easy","sampleInput":"abc","sampleOutput":"abc\r\nbac\r\ncab\r\nacb\r\nbca\r\ncba","questionVideo":"https://www.youtube.com/embed/39SKIuA-ieY?end=286","hints":[],"associated":[{"id":"55805d19-0a79-49c1-a128-703839c92891","name":"Space complexity of Print All Permutations Of A String Iteratively","slug":"space-complexity-of-print-all-permutations-of-a-string-iteratively","type":4},{"id":"61e24bac-9f2e-4eac-9a40-49c8dfcd1451","name":"Time complexity of Print All Permutations Of A String Iteratively","slug":"time-complexity-of-print-all-permutations-of-a-string-iteratively","type":4},{"id":"a5c646a5-1443-47c3-863f-6b4761e01819","name":"What will be the total number of permutations if length of the given string is n?","slug":"what-will-be-the-total-number-of-permutations-if-length-of-the-given-string-is-n","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"28c4c414-93fc-4aa0-84dc-1c7e08313cdc","name":"String, Dynamic String and Dynamic Array","slug":"string-dynamic-string-and-dynamic-array","type":0},{"id":"18a9bf5c-b7b0-4836-9ff9-e32104f7b668","name":"Print All Permutations Of A String Iteratively","slug":"print-all-permutations-of-a-string-iteratively","type":1}],"next":{"id":"a7d4ebba-738e-4000-97dd-2f70ceec350b","name":"Print All Palindromic Substrings in Java","type":3,"slug":"print-all-palindromic-substrings-in-java"},"prev":{"id":"7a461c32-ffe8-449c-9b3e-94c12783383d","name":"Remove Primes","type":1,"slug":"remove-primes"}}}`

# Print All Permutations Of A String Iteratively

<p>1. You are given a string. 2. You have to print all permutations of the given string iteratively.</p>

`{"id":"132bc873-f130-4568-892f-e233b1301969","name":"Print All Permutations Of A String Iteratively","description":"<p>1. You are given a string. 2. You have to print all permutations of the given string iteratively.</p>","inputFormat":"A String","outputFormat":"All permutations of the given string(one in a line).","constraints":"1 &lt;= length of string &lt;= 15","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<string>\nusing namespace std;\n\n\nvoid printallperm(string str)\n{\n //write your code here\n}\nint main()\n{\n string str;\n getline(cin,str);\n \n printallperm(str);\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void solution(String str){\r\n\t\t// write your code here\r\n\t\t\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString str = scn.next();\r\n\t\tsolution(str);\r\n\t}\r\n\r\n}"},"python":{"code":"def printallperm(st):\n #write your code here\n\nst=input()\nprintallperm(st)"}},"points":10,"difficulty":"easy","sampleInput":"abc","sampleOutput":"abc\r\nbac\r\ncab\r\nacb\r\nbca\r\ncba","questionVideo":"https://www.youtube.com/embed/39SKIuA-ieY?end=286","hints":[],"associated":[{"id":"55805d19-0a79-49c1-a128-703839c92891","name":"Space complexity of Print All Permutations Of A String Iteratively","slug":"space-complexity-of-print-all-permutations-of-a-string-iteratively","type":4},{"id":"61e24bac-9f2e-4eac-9a40-49c8dfcd1451","name":"Time complexity of Print All Permutations Of A String Iteratively","slug":"time-complexity-of-print-all-permutations-of-a-string-iteratively","type":4},{"id":"a5c646a5-1443-47c3-863f-6b4761e01819","name":"What will be the total number of permutations if length of the given string is n?","slug":"what-will-be-the-total-number-of-permutations-if-length-of-the-given-string-is-n","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"28c4c414-93fc-4aa0-84dc-1c7e08313cdc","name":"String, Dynamic String and Dynamic Array","slug":"string-dynamic-string-and-dynamic-array","type":0},{"id":"18a9bf5c-b7b0-4836-9ff9-e32104f7b668","name":"Print All Permutations Of A String Iteratively","slug":"print-all-permutations-of-a-string-iteratively","type":1}],"next":{"id":"a7d4ebba-738e-4000-97dd-2f70ceec350b","name":"Print All Palindromic Substrings in Java","type":3,"slug":"print-all-palindromic-substrings-in-java"},"prev":{"id":"7a461c32-ffe8-449c-9b3e-94c12783383d","name":"Remove Primes","type":1,"slug":"remove-primes"}}}`

Editor

# Print All Permutations Of A String Iteratively

easy

1. You are given a string. 2. You have to print all permutations of the given string iteratively.

## Constraints

1 <= length of string <= 15

## Format

A String

### Output

All permutations of the given string(one in a line).

## Example

Sample Input

`.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}abc`

### Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}abc bac cab acb bca cba```

Question Video

Discussions

Show Discussion

Related Resources