FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CodeTest/leetcode/next-permutation.cpp at master · wheatwaves/CodeTest · GitHub
wheatwaves
/
CodeTest
Public
forked from
flexwang-zz/CodeTest
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
CodeTest
/
leetcode
/
next-permutation.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
17 lines (17 loc) · 460 Bytes
Breadcrumbs
CodeTest
/
leetcode
/
next-permutation.cpp
Copy path
File metadata and controls
17 lines (17 loc) · 460 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class
Solution
{
public:
void
nextPermutation
(vector<
int
>& nums) {
if
(nums.
size
() <=
1
)
return
;
int
p;
for
(p=nums.
size
()-
1
; p>
0
; p--)
if
(nums[p] > nums[p-
1
])
break
;
if
(p) {
int
p2;
for
(p2=nums.
size
()-
1
; p2>p; p2--)
if
(nums[p2] > nums[p-
1
])
break
;
swap
(nums[p2], nums[p-
1
]);
}
reverse
(nums.
begin
()+p, nums.
end
());
}
};
Back
|
FazBrowse Home
|
New Git URL