Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
as rowcased said, your code contains undefined behavior. you are accessing the vector past its last element. one property of undefined behavior is that it can cause code to work in one setting (your computer) and not in another (Codewars). this is not a kata issue, but a problem with your code.
It seems strange, because on my VS Code with compiler gcc 8.3.0 i have correct answer for {4,16,24} and {30,12}
I am not even sure this is possible, but it appears that, during a particular test, using
arr[i+1]
within a loop based oni < arr.size()
you end up causing UB by altering the elements of the following test'sarr1
?actual
refers to the value your code returns to the testing suiteso, your code is returning
4
for that test, whereas it should return12
for that testI have the problem with basic tests. In results actual value is 4, but 4 is not in tests.