Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 06c318c

Browse filesBrowse files
authored
Merge pull request AlgoStudyGroup#180 from FZYUAN-1/patch-8
Create 20-Permutation-Sequence.cpp
2 parents c286c26 + 2f04864 commit 06c318c
Copy full SHA for 06c318c

File tree

1 file changed

+15
-0
lines changed
Filter options

1 file changed

+15
-0
lines changed
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
string getPermutation(int n, int k) {
4+
vector<int> v(n);
5+
iota(v.begin(), v.end(), 1);
6+
while(k-1){
7+
next_permutation(v.begin(), v.end());
8+
--k;
9+
}
10+
string r;
11+
transform(v.begin(), v.end(), back_inserter(r), [](const int num) -> char { return num + '0'; });
12+
13+
return r;
14+
}
15+
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.