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.
The v is a parameter representing each element in the array
Why do they call this unreadable trash best practices?
Much better than the top-rated one, which makes 3 passes over the string. But there’s no need to count the length manually since std::string::size() (or length()) immediately returns the internally stored length.
Good kata, realistic bug. Thanks.
Please tell me how are "==" and 0 related? Everything works for me with "===".
I agree. The habit of checking the matching of variable types will also protect you from unobvious errors in the future.
This comment is hidden because it contains spoiler information about the solution
The problem states that the array has every integer from 1 to n exactly once except for some integer in between, which appears twice. The array that you're testing on doesn't fit this description (it has a 9 but no 6, for example), so the solution doesn't work.
I tried this with: arr = [1, 5, 7, 3, 2, 9, 2, 8]
And it returned 9 instead of 2 :/
Clever
This comment is hidden because it contains spoiler information about the solution
O(n²) instead of O(n).
gotcha.
...because that would have been an incorrect formula.
This comment is hidden because it contains spoiler information about the solution
Loading more items...