• Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This solution would "just traverse down". The loops uses the destination coordinates to avoid unnecessary calculations.

  • Custom User Avatar

    X denotes the column of the endpoint, or the horizontal point if you will.

    Y denotes the row of the endpoint, or the vertical point if you will.

    With coordinates (0, 0) it should be obvious why the minimum path is 1, since you're starting and ending at the same position with the value 1.

    Here is the minimum path of the grid given before, when the endpoint is in (0, 1):

    [1,_,_],
    [4,_,_],
    [_,_,_]
    
  • Custom User Avatar

    You always start at the upper left corner. Then, each nested array represents a row in the 2D-grid.

    In the test-case you're referencing you're given the following grid:

    [1,2,3],
    [4,8,2],
    [1,5,3]
    

    The end coordinate is x = 0, y = 1, which is where the 4 is in the grid. Therefore the minimum path will be 1 + 4 = 5.

  • Custom User Avatar

    The problem with this approach is that you're calculating the cost of every possible path in the matrix. As you can imagine, that is quite a lot of possibilities. There is a much smarter way solve this problem, that gives you a running time of O(n^2) if the matrix is quadratic (Hint: Dynamic programming).

  • Custom User Avatar

    That's intentional as to not clutter the test cases.

  • Custom User Avatar

    The tests have been made in a way that requires you to come up with an implementation that runs pretty fast. (Hint: dynamic programming)

  • Custom User Avatar

    You're not always asked to move to the lower right corner. The goal-coordinated can be any point in the grid.

  • Custom User Avatar

    Oh yeah. That should be fixed now. I've allowed the very big squares to be reused, as it would take to long to copy them.

  • Custom User Avatar

    You're right. I've made the individual tests copy the original grid, to fix this. Thanks for pointing that out.

  • Custom User Avatar

    Fixed.

  • Custom User Avatar

    I've changed the order now. Thanks for the feedback!

  • Custom User Avatar

    I really can't see where they're in the wrong order, please specify.

    assertEquals(java.lang.Object expected, java.lang.Object actual) 
              Asserts that two objects are equal.
    
  • Custom User Avatar

    Thanks for the feedback!
    I've added units to the input specifications.

  • Custom User Avatar

    Missing test cases in Java

  • Loading more items...