Ad
  • Default User Avatar

    Interesting task!

    (Note: generator functions as presented in this problem slightly diverge from generator functions in actual JS, but it's a little simpler this way.)

    To me it's the opposite. I think this makes it more complex, because the first next call behaves differently from subsequent ones.

  • Default User Avatar

    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.

  • Default User Avatar

    What if someone wanted to join more than 3 tables?

  • Custom User Avatar

    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.

  • Default User Avatar

    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).

  • Custom User Avatar

    There are already tests with duplicate points, it would not bring any value to the task.

  • Default User Avatar

    Test case for worst case scenario (when all points have the same x or y value) is missing.

  • Default User Avatar

    For each node, lookup in a map is performed twice: map.containsKey(current) and map.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 of containsKey.