Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

help in different version of "Kill Anton"

Revision en1, by user311, 2021-08-04 19:21:10

I didn't notice that as per the question statement, we can only switch adjacent characters to reach the original string.

If this wasn't the case and we could switch any characters of the string, how would you solve it.

I wrote a greedy solution: complete as many possible cycles of A -> N -> T -> O -> A until we exhaust the least frequent character. Followed by smaller and smaller cycles.

by completing cycles A -> N -> O -> A, I mean swap 'A' and 'N', swap 'N' and 'O' and so on.

code

Code

Link to Problem

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English user311 2021-08-04 19:21:10 1908 Initial revision (published)