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 kata is available in almost 20 languages. Some of those use lists, others use arrays, sequences, vectors, .. it can seem like every language invents its own word for "list" ( also depending on the implementation ).
Sometimes you have to read a description ( or initial code ) and translate concepts to your language of choice yourself.
The name of the parameter is misleading, it should be list not arr(array)
Agree
Why do you believe it's allocated with
malloc()
? It's not, it is a regularint
that is passed by reference to your function.I'm understand now. There was reserved an empty space with malloc
that I need to fill with some value.
You seem to be a bit confused about how output parameters work. In this challenge, the pointer
first
will always point to a valid location which can hold anint
value. You solution has to use this location and write anint
value into it. The pointer is always valid, but the pointed value is undetermined and your solution has to fill it in.I thought that it must be point to NULL
and only the answer will change it to a valid int.
Does it happen that
first
is a null pointer? It seems to be defined by the setup as a not-optional output parameter, and, as such, it will always be passed as a pointer to a validint
?Hello.
For C language, if int* first is a null pointer, why *first = arr[i] works?
It must be null pointer dereferencing mistake.
This should really be a 7kyu. ( So if you find it hard for an 8kyu, that might be correct. )
Don't hold your breath everyone, but I'll raise the issue at the appropriate place.
Approved
C++ translation ready for review (author is inactive).
It was a cool kata, gives me the vibes of leetcode even tho way easier than any leetcode. But this kata is deffo not 8 kyu, it gotta be atleast 7 or 6
The kata works just fine, the problem is in your code, read the test label, print the input, create a sample test and figure out why your code fails:
Read this: https://docs.codewars.com/training/troubleshooting/#print-input
This Kata does not work. I entered in the code that was equivelent to the solution and the null solution kept on returning undefined.
Loading more items...