Anda di halaman 1dari 2

7/29/2017 TCS: CodeVita - Coding Arena

TC S NextStep TC S C areers www.tcs.com Logout

Welcome SHASHANK SHEKHAR Home Coding Arena Compile & Run Submissions Graphs Feedback

Time Left

Coding Arena 00 02 32
Change Default Language hr min sec

A B C D E F

Rules & Regulations


Problem : Palindrome sorting
Launch Code Editor
A palindrome is a word, phrase, or sequence that reads the same backwards as forwards. Given a palindrome write a
program to print the sorted list of all palindromes that can be constructed from the alphabets of the given palindrome. All Notifications
palindromes should start in a newline.

Input Format: Status messages

One string (palindrome)

Output Format:

A sorted list of all palindromes constructed from the given string. Each line should contain one palindrome.

Example 1

Input
NITIN

Output
INTNI
NITIN

Explanation
There are only two palindromes that can be constructed from NITIN

Example 2

Input
ABC DC BA

Output
ABC DC BA
AC BDBC A
BAC DC AB
BC ADAC B
C ABDBAC
C BADABC

Explanation
Since there is only one D, it can only be the middle letter in the palindrome. The remaining lettere A, B, C can be arranged
in 6 possible ways and each way gives rise to a palindrome.

Note:

Please do not use package and namespace in your code. For object oriented languages your code should be written in one
class.
Note:

Participants submitting solutions in C language should not use functions from <conio.h> / <process.h> as these files do not
exist in gcc
Note:

For C and C++, return type of main() function should be int.

2017 Tata Consultancy Services Limited. All Rights Reserved.

Submit Answer

I , SHASHANK SHEKHAR confirm that the answer submitted is my own.


I would like to provide attribution to the following sources.

Select Language
Select File
Browse...

https://www.tcscodevita.com/CodevitaV6/problemstart.jsp 1/2
7/29/2017 TCS: CodeVita - Coding Arena

2017 Tata C onsultancy Services Limited. All Rights Reserved. In Association with | Privacy Policy

https://www.tcscodevita.com/CodevitaV6/problemstart.jsp 2/2

Anda mungkin juga menyukai