std::vector<int> deleteNth(std::vector<int> arr, int n)
{
std::vector<int> arr2 = arr;
std::vector<int> positionstodelete;
unsigned short counter;
unsigned short lengthofmotives = arr.size();
unsigned short currentnumber;
for (int i = 0; i < lengthofmotives-1; i++){
counter = 1;
currentnumber = i;
for(int i = currentnumber; i < lengthofmotives-1;i++){
if (arr2[currentnumber] == arr2[i+1]){
counter++;
if(counter > n){
positionstodelete.push_back(i+1);
counter--;
}
}
}
}
size_t postodelsize = positionstodelete.size();
if (postodelsize > 1){
for(int i = postodelsize; i > 0; i--){
arr2.erase(arr2.begin() + positionstodelete[i]);
}
} else if (postodelsize == 1){
arr2.erase(arr2.begin() + positionstodelete[0]);
}
return arr2;
}
Kiedy odpalam ten kod na codewars'ach to wyskakuje mi ten błąd
STDERR " UndefinedBehaviorSanitizer:DEADLYSIGNAL
==1==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x0000016d8000 (pc 0x7fe790e16cf1 bp 0x0000016ca390 sp 0x7ffe0cacc418 T1)
==1==The signal is caused by a READ memory access.
==1==WARNING: invalid path to external symbolizer!
==1==WARNING: Failed to use and restart external symbolizer!
#0 0x7fe790e16cf0 (/lib/x86_64-linux-gnu/libc.so.6+0x18ecf0)
#1 0x4258bd (/workspace/test+0x4258bd)
#2 0x4284a8 (/workspace/test+0x4284a8)
3 0x426aae (/workspace/test+0x426aae)
#4 0x4264dd (/workspace/test+0x4264dd)
#5 0x4261cb (/workspace/test+0x4261cb)
6 0x42c8d5 (/workspace/test+0x42c8d5)
#7 0x4259bd (/workspace/test+0x4259bd)
#8 0x7fe790ca9bf6 (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
#9 0x4046f9 (/workspace/test+0x4046f9)
UndefinedBehaviorSanitizer can not provide additional info.
==1==ABORTING"
https://www.codewars.com/kata/554ca54ffa7d91b236000023/train/cpp
nie wiem o co chodzi, mógłby ktoś przejrzeć ten kod i poprawić tak żeby działał bo siedze już 3 godziny nad tym i nic nie działa