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
i think the increment could be i+=3 instead of i++
so u can simplify the ret calculation into
ret += 1f/i
xD
This comment is hidden because it contains spoiler information about the solution
I could add an additional condition that is AND in the loop which is
0 > openBracesCtr
.Something like this:
for(auto i = index+1; i < str.size() && 0 > openBracesCtr; ++i)
{
//same as before, but break can now be removed.
}
Btw, in my opinion both solutions have similar performance. I guess it's for coders preference on which is more reable. Anyways, thanks for the suggestion. It's good to think a way in tweaking existing solutions. :)
i suggest adjusting the loop condition instead of using break inside the loop, unless it's a must :')
Most compilers will optimize the code so that size() isn't called every iteration. In theory, you are correct, though.
Suppose size_t i instead of int i would be more correct as well. Iterators probably could have a case here.
This comment is hidden because it contains spoiler information about the solution
Im attemping in C#.
When i run sample test on test 1 it passes (case 1: empty | case 2: 3 pairs)
But when i attempt, it doesn't pass test 1(case 2) and my output array is missing the last pair :O
i tested it again with online complier and it gives correct array with 3 pairs :thonking: