Anda di halaman 1dari 2

7/29/2017

TCS: CodeVita - Coding Arena

TCS NextStep TCS Careers www.tcs.com Logout Welcome SHASHANK SHEKHAR Home Coding Arena Compile & Run Submissions
TCS NextStep
TCS Careers
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

Problem : Palindrome sorting

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 palindromes should start in a newline.

Input Format:

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

ABCDCBA

Output

ABCDCBA

ACBDBCA

BACDCAB

BCADACB

CABDBAC

CBADABC

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...
Browse...

7/29/2017

TCS: CodeVita - Coding Arena

© 2017 Tata Consultancy Services Limited. All Rights Reserved.

In Association with

7/29/2017 TCS: CodeVita - Coding Arena © 2017 Tata Consultancy Services Limited. All Rights Reserved. InPrivacy Policy https://www.tcscodevita.com/CodevitaV6/problemstart.jsp 2/2 " id="pdf-obj-1-11" src="pdf-obj-1-11.jpg">
7/29/2017 TCS: CodeVita - Coding Arena © 2017 Tata Consultancy Services Limited. All Rights Reserved. InPrivacy Policy https://www.tcscodevita.com/CodevitaV6/problemstart.jsp 2/2 " id="pdf-obj-1-16" src="pdf-obj-1-16.jpg">