Problem Β· String

Lexicographically Smallest Palindrome Possible 🍊

Learn this problem
● MediumAmazonOA
See Amazon hiring insights

Problem statement

Given a String, return the lexicographically smallest palindrome possible or -1.

Function

getSmallestPalindrome(s: String) β†’ String

Examples

Example 1

s = "a?rt???"return = "aartraa"
Question marks can be replaced by a, r, a, a and we can make it palindrome.

Example 2

s = "bx??tm"return = "-1"
No character can be added to make it a palindrome.

Example 3

s = "ai?a??u"return = "aaiuiaa"
'?' is replaced by a, a and i and characters are rearranged to make it a palindrome.

Constraints

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

More Amazon problems

drafts saved locally
public String getSmallestPalindrome(String s) {
  // write your code here
}
s"a?rt???"
expected"aartraa"
checking account