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
While this adds properties to the nodes, if this is okay, then this will find the loop length in O(k+n) (worst-case) time, where
k = <tail_length>
&&n = <loop_length>
. If the<tail_length>
is zero, then we're presented with the best-case. Removing the leading constantk
, we get O(n) time complexity. If adding properties to the nodes is not permitted, then we would need to iterate back and remove the added properties, leaving us with a time complexity of O(2k + 2n) (worst-case). Remove the leading constantk
(<tail_length>
of zero) and we're presented with the best-case of O(2n).Discaimer: Still pretty new to analyzing computational algorithms so please correct me if I'm wrong here. Also, I welcome any criticism of my approach to the problem.
Thanks all :-)
Accounts for missing tests
long > 180
andlong < -180
lol, just realized this kata doesn't test for longitude coords > 180 or < -180. This solution is incorrect.