cswork / OA打开练习工作台

AmazonOA #251

Lexicographically Smallest Palindrome Possible

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)哈希计数字符串贪心调度

Giv

Constraints

A mysterious untelling for now As always, will add once find out

Example 1

Input:

s = "a?rt???"

Output:

"aartraa"

Explanation: Question marks can be replaced by a, r, a, a and we can make it palindrome.

Example 2

Input:

s = "bx??tm"

Output:

"-1"

Explanation: No character can be added to make it a palindrome.

Example 3

Input:

s = "ai?a??u"

Output:

"aaiuiaa"

Explanation: '?' is replaced by a, a and i and characters are rearranged to make it a palindrome.