10716 - Evil Straw Warts Live
Moderator: Board moderators
-
- New poster
- Posts: 24
- Joined: Sun Oct 03, 2004 10:03 am
10716 - Evil Straw Warts Live
Can anybody explain how to sovle such problems?
Hi!
My solution (which got AC
was quite simple :
for each letter find it's first and last occurence in current string.
select letter for which sum of distances from it's first occurence to beginning and from last one to the end is smallest.
"move it" I mean swap it's first occurence to beginning and last to the end.
and "eliminate" them --> now you have the word which is shorter.
you have to repeat until you have <=1 letters left.
(oh you have to look whether this word can be "swapped" into the palindrom first)
Good Luck
My solution (which got AC

for each letter find it's first and last occurence in current string.
select letter for which sum of distances from it's first occurence to beginning and from last one to the end is smallest.
"move it" I mean swap it's first occurence to beginning and last to the end.
and "eliminate" them --> now you have the word which is shorter.
you have to repeat until you have <=1 letters left.
(oh you have to look whether this word can be "swapped" into the palindrom first)
Good Luck