MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / next_permutation

Method next_permutation

679. 24 Game/Solution.cpp:66–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64 }
65
66 void next_permutation(vector<int> & nums) {
67 int i = nums.size() - 1;
68 while (i >= 0) {
69 if (i != 0 and nums[i - 1] < nums[i] ) {
70 int j = 3;
71 while (nums[j] <= nums[i - 1]) j -- ;
72 swap(nums[i - 1], nums[j]);
73 reverse(nums.begin() + i, nums.end());
74 return;
75 } else if (i == 0) {
76 reverse(nums.begin(), nums.end());
77 return;
78 }
79 i -- ;
80 }
81 }
82
83 string to_str(Ops op) {
84 switch (op) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected