{"id":"5c613214-a18c-4ec9-81f5-62becd2d6049","name":"Print All Palindromic Substrings","description":"1. You are given a string. \r\n2. You have to print all palindromic substrings of the given string.","inputFormat":"A String","outputFormat":"All palindromic substrings(one in a line).\r\nFirst, all palindromic substrings starting from first character of string will be printed, then from second character and so on.","constraints":"1 &lt;= length of string &lt;= 500","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<string.h>\nusing namespace std;\nvoid printallpralindrome(string str)\n{\n //write your code here\n}\n\nint main()\n{\n string str;\n getline(cin,str);\n printallpalindrome(str);\n return 0;\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\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 printallpalindrome(st):\n #write your code here\n\nst = str(input())\nprinallpalindrome(st)"}},"points":10,"difficulty":"easy","sampleInput":"abcc","sampleOutput":"a\r\nb\r\nc\r\ncc\r\nc","questionVideo":"https://www.youtube.com/embed/_jM3iMT4k7g?end=88","hints":[],"associated":[{"id":"3efdc5f7-700c-4865-8c82-a2f364e82406","name":"What should you use for this question?","slug":"what-should-you-use-for-this-question","type":4},{"id":"c9e52798-fb37-46bf-b618-d7ade8315f4b","name":"Which of the following is not a palindromic subsequence of the string “ababcdabba”?","slug":"which-of-the-following-is-not-a-palindromic-subsequence-of-the-string-ababcdabba","type":4},{"id":"db289b54-b3ea-4d7f-a8cd-1ead29f5facd","name":"What is the overall time complexity of this approach?","slug":"what-is-the-overall-time-complexity-of-this-approach","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":"c074693d-bc3c-46ce-a318-a2ecfb2ece49","name":"Print All Palindromic Substrings","slug":"print-all-palindromic-substrings","type":1}],"next":{"id":"8d70323f-f00c-4b50-ad47-070a292e27f3","name":"String Compression","type":1,"slug":"string-compression"},"prev":{"id":"57d72b9b-9859-479e-86da-23864984b944","name":"Introduction to Strings in Java","type":3,"slug":"introduction-to-strings-in-java"}}}

Print All Palindromic Substrings

1. You are given a string. 2. You have to print all palindromic substrings of the given string.

{"id":"5c613214-a18c-4ec9-81f5-62becd2d6049","name":"Print All Palindromic Substrings","description":"1. You are given a string. \r\n2. You have to print all palindromic substrings of the given string.","inputFormat":"A String","outputFormat":"All palindromic substrings(one in a line).\r\nFirst, all palindromic substrings starting from first character of string will be printed, then from second character and so on.","constraints":"1 &lt;= length of string &lt;= 500","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<string.h>\nusing namespace std;\nvoid printallpralindrome(string str)\n{\n //write your code here\n}\n\nint main()\n{\n string str;\n getline(cin,str);\n printallpalindrome(str);\n return 0;\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\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 printallpalindrome(st):\n #write your code here\n\nst = str(input())\nprinallpalindrome(st)"}},"points":10,"difficulty":"easy","sampleInput":"abcc","sampleOutput":"a\r\nb\r\nc\r\ncc\r\nc","questionVideo":"https://www.youtube.com/embed/_jM3iMT4k7g?end=88","hints":[],"associated":[{"id":"3efdc5f7-700c-4865-8c82-a2f364e82406","name":"What should you use for this question?","slug":"what-should-you-use-for-this-question","type":4},{"id":"c9e52798-fb37-46bf-b618-d7ade8315f4b","name":"Which of the following is not a palindromic subsequence of the string “ababcdabba”?","slug":"which-of-the-following-is-not-a-palindromic-subsequence-of-the-string-ababcdabba","type":4},{"id":"db289b54-b3ea-4d7f-a8cd-1ead29f5facd","name":"What is the overall time complexity of this approach?","slug":"what-is-the-overall-time-complexity-of-this-approach","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":"c074693d-bc3c-46ce-a318-a2ecfb2ece49","name":"Print All Palindromic Substrings","slug":"print-all-palindromic-substrings","type":1}],"next":{"id":"8d70323f-f00c-4b50-ad47-070a292e27f3","name":"String Compression","type":1,"slug":"string-compression"},"prev":{"id":"57d72b9b-9859-479e-86da-23864984b944","name":"Introduction to Strings in Java","type":3,"slug":"introduction-to-strings-in-java"}}}
plane

Editor


Loading...

Print All Palindromic Substrings

easy

1. You are given a string. 2. You have to print all palindromic substrings of the given string.

Constraints

1 <= length of string <= 500

Format

Input

A String

Output

All palindromic substrings(one in a line). First, all palindromic substrings starting from first character of string will be printed, then from second character and so on.

Example

Sample Input

abcc

Sample Output

a b c cc c

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode