Sunday, July 26, 2015

HackerRank::Algorithms::Greedy::Largest Permutation

  We are aiming to build the following sequence, N, N-1, N-2, ... .If we have at least one swap, then we should use it in order to bring the number N to front regardless of the other numbers' positions. Then if we have some swaps left we should bring the Number N-1 to the second position, and then the number N-2 to the third position and so on.



No comments:

Post a Comment