Skip to content

Commit 8bd6e44

Browse files
committed
Solution as on 20-03-2022 08:31 pm
1 parent 71dfacb commit 8bd6e44

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

0060. Permutation Sequence.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// 60.✅ Permutation Sequence
2+
3+
class Solution
4+
{
5+
public:
6+
string getPermutation(int n, int k)
7+
{
8+
int num = 0;
9+
10+
for (int i = 1; i <= n; ++i)
11+
num = num * 10 + i;
12+
13+
string s = to_string(num);
14+
15+
k--;
16+
while (k--)
17+
{
18+
next_permutation(s.begin(), s.end());
19+
}
20+
21+
return s;
22+
}
23+
};

0 commit comments

Comments
 (0)