題目: — Minimum Adjacent Swaps to Reach the Kth Smallest Number - LeetCode
You are given a string num, representing a large integer, and an integer k. We call some integer wonderful if it is a…leetcode.com 我自己因為想這題想了很久,所以還是忍不住去看 hint 了。。。羞愧之餘,順手將解答給記錄下來。 解這題前,首先需要會 Next Permutation ,會了之後就會變得相當簡單了。 我的解答: class Solution { public: void swap(char &a, char &b) {
char t;
t = a;
a = b …