{"id":"7bff918d-33a8-4e49-a3fb-86f81d7bf87d","name":"Shortest Palindrome","description":"1. You are given string(str). \r\n2. You can convert the given string to a palindrome by adding some characters in front of it.\r\n3. You have to find the shortest palindromic string formed after performing the above-mentioned transformation. ","inputFormat":"A string","outputFormat":"A string","constraints":"1 <= length of the string <= 10^4","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static String solution(String str){\r\n // write your code here\r\n \r\n return null;\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n Scanner scn = new Scanner(System.in);\r\n String str = scn.next();\r\n System.out.println(solution(str));\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"coding","sampleOutput":"gnidocoding\r\n","questionVideo":"https://www.youtube.com/embed/M0Nwvd-G-tg","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":"a2073e25-96a1-4875-b400-f40bbe2edd95","name":"Text Processing For Experts","slug":"text-processing-for-experts-859","type":0},{"id":"c01c3424-51ff-47f1-95c8-710635fd2aed","name":"Shortest Palindrome","slug":"shortest-palindrome","type":1}],"next":{"id":"3b0de180-8222-4a11-8dca-116ef481da5a","name":"Kmp Pattern Searching","type":1,"slug":"kmp-pattern-searching"},"prev":null}}

Shortest Palindrome

1. You are given string(str). 2. You can convert the given string to a palindrome by adding some characters in front of it. 3. You have to find the shortest palindromic string formed after performing the above-mentioned transformation.

{"id":"7bff918d-33a8-4e49-a3fb-86f81d7bf87d","name":"Shortest Palindrome","description":"1. You are given string(str). \r\n2. You can convert the given string to a palindrome by adding some characters in front of it.\r\n3. You have to find the shortest palindromic string formed after performing the above-mentioned transformation. ","inputFormat":"A string","outputFormat":"A string","constraints":"1 <= length of the string <= 10^4","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static String solution(String str){\r\n // write your code here\r\n \r\n return null;\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n Scanner scn = new Scanner(System.in);\r\n String str = scn.next();\r\n System.out.println(solution(str));\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"coding","sampleOutput":"gnidocoding\r\n","questionVideo":"https://www.youtube.com/embed/M0Nwvd-G-tg","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":"a2073e25-96a1-4875-b400-f40bbe2edd95","name":"Text Processing For Experts","slug":"text-processing-for-experts-859","type":0},{"id":"c01c3424-51ff-47f1-95c8-710635fd2aed","name":"Shortest Palindrome","slug":"shortest-palindrome","type":1}],"next":{"id":"3b0de180-8222-4a11-8dca-116ef481da5a","name":"Kmp Pattern Searching","type":1,"slug":"kmp-pattern-searching"},"prev":null}}
plane

Editor


Loading...

Shortest Palindrome

hard

1. You are given string(str). 2. You can convert the given string to a palindrome by adding some characters in front of it. 3. You have to find the shortest palindromic string formed after performing the above-mentioned transformation.

Constraints

1 <= length of the string <= 10^4

Format

Input

A string

Output

A string

Example

Sample Input

coding

Sample Output

gnidocoding

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode