Skip to content

Commit b9ef2c8

Browse files
committedAug 9, 2021
Time: 132 ms (18.29%), Space: 5.9 MB (78.00%) - LeetHub
1 parent d8fb852 commit b9ef2c8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
public:
3+
string getPermutation(int n, int k) {
4+
string str = "";
5+
for (int i = 1; i <= n; ++i) {
6+
str += to_string(i);
7+
}
8+
9+
int cnt = 1;
10+
if (k == 1)
11+
return str;
12+
while (next_permutation(str.begin(), str.end())) {
13+
cnt++;
14+
if (cnt == k)
15+
return str;
16+
}
17+
18+
return str;
19+
}
20+
};

0 commit comments

Comments
 (0)