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 task is to construct and return a regular expression pattern, that will match a binary number only if it is divisible by 7. The numbers are never passed to the function to be implemented.
For example, if the task was to match binary numbers divisible by 2 (which is trivial), you would return:
Pattern.compile("^[01]*0$")
. This task is much more complex, of course.What if someone wanted to join more than 3 tables?
I was considering adding such tests, but it was difficult for me back then to judge what should be its size, how many of them is needed, etc. Now you raised the remark, I think I will consider it once again and think of something.
I meant a case, when all points have the same x value, forming a straight line, paralell to y axis. In my solution I don't sort the points in the strip, but I still pass all the tests, becasue the number of points in the strip is relatively small. With all points having the same x value, all points end up in the strip, and such solution degrades to O(n^2).
There are already tests with duplicate points, it would not bring any value to the task.
Test case for worst case scenario (when all points have the same x or y value) is missing.
For each node, lookup in a map is performed twice:
map.containsKey(current)
andmap.put(current, i)
. This can be avoided:put
returns previous value associated with key, which can be used instead to check existance of the node instead ofcontainsKey
.