问题描述
我正在解决一个关于 Leetcode(Next Permutation) 的问题
class Solution {
public:
void nextPermutation(vector<int>& nums) {
int i=nums.size()-2;
while(i>=0 && nums[i]>nums[i+1])
{
i--;
}
int j=nums.size()-1;
if(i>=0)
{
while(j>=0 && nums[j]<=nums[i]){
j--;
}
swap(nums[i],nums[j]);
}
reverse(nums.begin()+i+1,nums.end());
}
};
这是我唯一需要编辑的部分。在运行它时,我收到以下错误
Line 1034: Char 34: runtime error: addition of unsigned offset to 0x602000000470 overflowed to 0x60200000046c (stl_vector.h)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1043:34
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)