- Greedy, lexicographic-ordering, Mathematical, permutation, Strings

Minimum adjacent swaps required to get Kth smallest number greater than given number

#include using namespace std;  void minSwapsKthLargest(string str, int k){        string res = str;              for (int i = 0; i < k; i++) {        next_permutation(            str.begin(), str.end());    }          int swap_count = 0;              for (int i = 0; i < res.length(); i++) {                  if (res[i] != str[i]) {            int start = i + 1;                          while (res[i] != str[start]) {                                  start++;            }            while (i != start) {                swap(str[start], str[start - 1]);                                                  start--;                swap_count++;            }        }    }          cout