Ad
  • Custom User Avatar

    and the check for length can be done before the loop

  • Default User Avatar

    exactly, strange it got so many 'clever' votes.

  • Custom User Avatar

    A null input should either throw a NullPointerException (discouraged) or should gracefully delegate the null-handling back to the caller by returning null (prefered).
    Converting null to an empty string (or any other "empty" object, for that matter) is a bad practice that leads to confusion in more complex code as to where exactly the unexpected "empty" dummy object originated from. An empty string is no different from any other empty object – it has no semantic value but is merely a meaningless stopgap. DON'T PRODUCE EMPTY OBJECTS!

  • Custom User Avatar

    I have not considered this yet. I believe if 2 (or more) solutions both have the shortest length, either one should be accepted, as the criteria states

    "The shortest solution is the one containing the least nodes labeled 'P'."

    So, they would both work. I will add this later, thanks.

  • Default User Avatar

    For some matrices, there are multiple solutions. It's unclear how to choose between them. For example:

    X S X
    . X .
    X G X

    has two solutions with the same path length. How do you choose between them?

  • Default User Avatar

    There is a small issue with the default test: Assert.assertEquals should be simply assertEquals.

  • Custom User Avatar

    Thanks but don't deserve an issue that are for rather big problems:-)

  • Default User Avatar

    There's a typo in the solution template for java - ouor should be "your"

  • Custom User Avatar

    Already written :
    2) The encode method should return an empty String if a null parameter is passed.

  • Default User Avatar

    The description should mention how null input should be handled.

  • Default User Avatar

    This doesn't work - try {'n', 'w', 'n', 'w', 'n', 'w', 'n', 'w', 'n', 'w'} as input.