Skip to main content
1 of 2
Fhuvi
  • 2.3k
  • 1
  • 8
  • 24

JavaScript (Node.js), 90 bytes

JS is clearly not the right tool for this job, but i'm surprised no one posted a JS answer before!

I'm not sure if this is the shortest approach, but this is the best i could come up with :)

For each character of the word, we test if the removal of this character gives a word that is a palindrome, and we retain the index +1 of the last character that succeeded (or -1 if there weren't any).

s=>[...s].map((e,i)=>r=(a=[...s]).splice(i,1)&&a.join``==a.reverse().join``?i+1:r,r=-1)&&r 

Try it online!

Fhuvi
  • 2.3k
  • 1
  • 8
  • 24