Given a string s
, return the smallest contiguous substring you can remove to create a palindrome.
Examples:
800233008 -> 2
racecarFOOL -> FOOL
abcdedcba -> (empty string)
ngryL Myrgn -> "L " (or " M")
123456789 -> 12345678 (or 23456789)
aabcdbaa -> c (or d)
[[]] -> [[ (or ]])
a -> (empty string)
Test case suggestions from users (if you find an edge case not listed, please post a comment):
aabaab -> b | Suggested by Zgarb, some returned "aa".
Rules
- Only printable ASCII characters will appear in the input (no newlines, keep it simple).
- Not really a rule, but note
<>
,/\
,()
,[]
and{}
are not palindromes.
This is code-golf, smallest byte-count wins.
+100 bounty has been claimed by Adnan
aabaab
\$\endgroup\$ – Zgarb Nov 6 '17 at 17:46[[]]
a palindrome? \$\endgroup\$ – Carl Nov 7 '17 at 1:46]][[
. Consider thataabb
is the same thing, just different characters. \$\endgroup\$ – Conor O'Brien Nov 7 '17 at 3:25