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

  • Default User Avatar

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

  • Default User Avatar

    I have the same problem and i think my code is efficient because i use recursion to go trough all possible paths and storing the total sum in a list, at the end i return the smallest element of the list. Does it still have to be more efficient? Or is it probaby because i use a global list to solve the problem? (i'll put the code as a reply to this msg marked as spoiler)

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