go_anjji_go's blog

By go_anjji_go, history, 4 years ago, In English

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.

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it