`{"id":"8c3c2053-d66a-49f5-979f-e417e333c67c","name":"All Palindromic Permutations","description":"1. You are given a string of length n.\r\n2. You have to print all the palindromic permutations of the given string.\r\n3. If no palindromic permutation exists for the given string, print \"-1\".\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"A String of length n","outputFormat":"Check the sample ouput and question video.","constraints":"1 &lt;= length of string &lt;= 15","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void generatepw(int cs, int ts, HashMap<Character, Integer> fmap, Character oddc, String asf) {\r\n\t\t\r\n\t}\r\n\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\tHashMap<Character, Integer> fmap = new HashMap<>();\r\n\t\tfor (int i = 0; i < str.length(); i++) {\r\n\t\t\tchar ch = str.charAt(i);\r\n\t\t\tfmap.put(ch, fmap.getOrDefault(ch, 0) + 1);\r\n\t\t}\r\n\t\t\r\n\t\t//write your code here\r\n\t}\r\n\t\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"aaabb","sampleOutput":"ababa\r\nbaaab\r\n","questionVideo":"https://www.youtube.com/embed/DwdWafLsGm0?end=101","hints":[],"associated":[],"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":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"03be5810-4a0c-4ce0-a2aa-90731b73c8c0","name":"All Palindromic Permutations","slug":"all-palindromic-permutations","type":1}],"next":{"id":"11761899-e2f2-437b-a7cf-0348fd6d53e8","name":"All Palindromic Permutations MCQ","type":0,"slug":"all-palindromic-permutations-mcq"},"prev":{"id":"ac2a2f14-7608-4839-b158-764f82f01964","name":"All Palindromic Partitions","type":3,"slug":"all-palindromic-partitions"}}}`

All Palindromic Permutations

1. You are given a string of length n. 2. You have to print all the palindromic permutations of the given string. 3. If no palindromic permutation exists for the given string, print "-1". Note -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

`{"id":"8c3c2053-d66a-49f5-979f-e417e333c67c","name":"All Palindromic Permutations","description":"1. You are given a string of length n.\r\n2. You have to print all the palindromic permutations of the given string.\r\n3. If no palindromic permutation exists for the given string, print \"-1\".\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"A String of length n","outputFormat":"Check the sample ouput and question video.","constraints":"1 &lt;= length of string &lt;= 15","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void generatepw(int cs, int ts, HashMap<Character, Integer> fmap, Character oddc, String asf) {\r\n\t\t\r\n\t}\r\n\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\tHashMap<Character, Integer> fmap = new HashMap<>();\r\n\t\tfor (int i = 0; i < str.length(); i++) {\r\n\t\t\tchar ch = str.charAt(i);\r\n\t\t\tfmap.put(ch, fmap.getOrDefault(ch, 0) + 1);\r\n\t\t}\r\n\t\t\r\n\t\t//write your code here\r\n\t}\r\n\t\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"aaabb","sampleOutput":"ababa\r\nbaaab\r\n","questionVideo":"https://www.youtube.com/embed/DwdWafLsGm0?end=101","hints":[],"associated":[],"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":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"03be5810-4a0c-4ce0-a2aa-90731b73c8c0","name":"All Palindromic Permutations","slug":"all-palindromic-permutations","type":1}],"next":{"id":"11761899-e2f2-437b-a7cf-0348fd6d53e8","name":"All Palindromic Permutations MCQ","type":0,"slug":"all-palindromic-permutations-mcq"},"prev":{"id":"ac2a2f14-7608-4839-b158-764f82f01964","name":"All Palindromic Partitions","type":3,"slug":"all-palindromic-partitions"}}}`

Editor

All Palindromic Permutations

medium

1. You are given a string of length n. 2. You have to print all the palindromic permutations of the given string. 3. If no palindromic permutation exists for the given string, print "-1". Note -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

Constraints

1 <= length of string <= 15

Format

Input

A String of length n

Output

Check the sample ouput and question video.

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;}aaabb`

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;}ababa baaab ```

Question Video

Discussions

Show Discussion

Related Resources