fix: correct permutation iterator offset for k index
Adjust iterator advancement to account for 1-based k indexing. This fixes returning the wrong permutation when selecting the k-th result.
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto it = permutations.begin();
|
auto it = permutations.begin();
|
||||||
advance(it, k);
|
advance(it, k - 1);
|
||||||
|
|
||||||
string mirroredHalf = *it;
|
string mirroredHalf = *it;
|
||||||
reverse(mirroredHalf);
|
reverse(mirroredHalf);
|
||||||
|
|||||||
Reference in New Issue
Block a user