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.
This comment is hidden because it contains spoiler information about the solution
Scala Sample Test /
Type Mismatch Error
If the numbers within the Seq() do not contain the L to state the numbers are long. Then the compiler will throw a
Type Mismatch Error
. Therefore you have to can bypass the sample tests by submitting. Or you can change sample test by adding theL
Example:
(Seq(9L), 9L),
(Seq(6L, 9L, 21L), 9L),
(Seq(1L, 21L, 55L), 3L)
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.
I meant O(n log(n)). And considering the number of people complaining about timeouts, they wrote a O(n^2) one.
You didn't write a O(log n) solution.
Problems like these have nothing to do with coding skills. If you know the algo, you can do it, otherwise you'll keep staring at it for a week and still get nowhere.
And has nothing to do with coding skills.
Perhaps a better approach would be to give the user a framework to run all the tests locally, so that they can debug failed tests using something better than printing to stdout.
Lua translation!
Brilliant coding challenge...
Hhahaha what the evil author, the description is completely misleading
Loading more items...