Category : dsa

I was solving the Next Permutation problem but I’m receiving the following error on Leetcode. Could any one point out what I am missing. Line 1034: Char 34: runtime error: addition of unsigned offset to 0x6020000002f0 overflowed to 0x6020000002ec (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 class Solution { public: void nextPermutation(vector<int>& nums) { int n=nums.size(); int ..

Read more

#include<iostream> #include<string> using namespace std; void subseq(string s, string ans) { if (s.size() == 0) { cout <<ans<< endl; } char ch = s[0]; int code = ch; string ros = s.substr(1); subseq(ros, ans); subseq(ros, ans+ch); subseq(ros, ans + std::to_string(code)); } int main() { cout<<subseq("AB", " "); return 0; } Error, as stated in IDE, ..

Read more