Maximal String

Revision en1, by go_anjji_go, 2020-08-08 10:09:02

You are given a string. You can perform at most K operations on this string. In each operation, you take two different indices i and j and swap the characters at these positions. What is the maximal lexicographical string that you can obtain. This question can be solved using backtracking but I was looking for some other efficient approach, maybe greedy or DP. Kindly share your views.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English go_anjji_go 2020-08-08 10:09:02 409 Initial revision (published)