Connection Status:
Competition Arena > MountainP
SRM 97 · 2002-06-12 · by brett1479
Class Name: MountainP
Return Type: String
Method Name: makeMP
Arg Types: (string)
Problem Statement

Problem Statement

To make a Mountain Palindrome from a given String you must sort the String's characters in ascending order and then append the fewest number of characters required for it to be a palindrome. A palindrome is a string that is the same backwards as forwards. For example, "ABCCBA", "DEED", and "RADAR" are all palindromes.

Create a class MountainP that contains the method makeMP, which takes a String before and returns a String that is the generated Mountain Palindrome.

Notes

  • Remember to append the FEWEST number of characters required to produce a palindrome.

Constraints

  • before will have between 1 and 25 characters, inclusive.
  • before will only contain capital letters ('A'-'Z').
Examples
0)
"BEFORESTRING"
Returns: "BEEFGINORRSTSRRONIGFEEB"

First we sort: "BEEFGINORRST" Next we append the fewest number of characters required to produce a palindrome.

1)
"AZZAZ"
Returns: "AAZZZAA"

First we sort: "AAZZZ" Next we append the fewest number of characters required to produce a palindrome.

2)
"A"
Returns: "A"
3)
"TOPCODER"
Returns: "CDEOOPRTRPOOEDC"
4)
"GRRRRR"
Returns: "GRRRRRG"

Submissions are judged against all 41 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class MountainP with a public method string makeMP(string before) · 41 test cases · 2 s / 256 MB per case

Submitting as anonymous