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.
Nobody's going to change the kata in the way you suggested years after it was approved.
Will fail in case nodes addreess are not monotonically increase/decrease:
Will fail in case nodes addreess are not monotonically increase/decrease:
Thank you for your comment. Unfortunately, it is probably too late to make changes to the problem condition, since all decisions of users who used the libraries will be invalid. I will definitely consider your proposal in the future.
Thanks for the kata! Although it would be more difficult and more fun if imports were disabled :)
Nice kata, thanks! A couple of comments:
Exactly! :)
Mine is O(logN), in Python. It's a binary search.
Very nice kata, thanks!
This comment is hidden because it contains spoiler information about the solution
Wow, nice to see the reference to Uncle Bob, I like this guy too :) Totally agree.
Very nice kata, thanks a lot!
This comment is hidden because it contains spoiler information about the solution
Have someone implemented solution with better than linear (O(n)) time complexity?
The probem is that in expression
d = a/n;
'a' is (signed)int
but 'n' issize_t
(which isunsigned long
). Asunsigned long
(64 bits) is longer thanint
(32 bits) the intermediate computation is performed asunsigned long
. In case 'a' is negative (i.e. the most significant bit is 1) after conversion tounsigned long
it would be a big positive number with 31st bit == 1. After division this bit is shifted right and the new 31st bit will be 0. After converson back toint
(assigning to 'd') the result would not be negative any more but an "odd number" :) To fix the issue used = a/(int)n
Loading more items...