Skip to main content
added 103 characters in body
Source Link

In event of multiple paths, a non-optimal solution may be returned.

Problem description clearly states there may be multiple solutions.

But in the test:

    List<Point> points1 = new ArrayList<Point>();
    points1.add(new Point(0, 0));
    //....more points........
    points1.add(new Point(2, 3));

    Assert.assertEquals(points1, lip.increasingPath(0, 0, 2, 3));

You compare the found solution (which is suboptimal) to itself after the fact. Instead you should verify that the solution is correct using the definition given in the question. e.g.

  • first element is the solution is the given start point,
  • last element is the given end point,
  • each point in the path is the neighbor to another.
  • and the values in the matrix corresponding to those points are non-decreasing.

I also don't like empty list as failure. I would prefer guava's Optional or something equivalent.

In event of multiple paths, a non-optimal solution may be returned.

Problem description clearly states there may be multiple solutions.

But in the test:

    List<Point> points1 = new ArrayList<Point>();
    points1.add(new Point(0, 0));
    //....more points........
    points1.add(new Point(2, 3));

    Assert.assertEquals(points1, lip.increasingPath(0, 0, 2, 3));

You compare the found solution (which is suboptimal) to itself after the fact. Instead you should verify that the solution is correct using the definition given in the question. e.g.

  • first element is the solution is the given start point,
  • last element is the given end point,
  • each point in the path is the neighbor to another.
  • and the values in the matrix corresponding to those points are non-decreasing.

In event of multiple paths, a non-optimal solution may be returned.

Problem description clearly states there may be multiple solutions.

But in the test:

    List<Point> points1 = new ArrayList<Point>();
    points1.add(new Point(0, 0));
    //....more points........
    points1.add(new Point(2, 3));

    Assert.assertEquals(points1, lip.increasingPath(0, 0, 2, 3));

You compare the found solution (which is suboptimal) to itself after the fact. Instead you should verify that the solution is correct using the definition given in the question. e.g.

  • first element is the solution is the given start point,
  • last element is the given end point,
  • each point in the path is the neighbor to another.
  • and the values in the matrix corresponding to those points are non-decreasing.

I also don't like empty list as failure. I would prefer guava's Optional or something equivalent.

Source Link

In event of multiple paths, a non-optimal solution may be returned.

Problem description clearly states there may be multiple solutions.

But in the test:

    List<Point> points1 = new ArrayList<Point>();
    points1.add(new Point(0, 0));
    //....more points........
    points1.add(new Point(2, 3));

    Assert.assertEquals(points1, lip.increasingPath(0, 0, 2, 3));

You compare the found solution (which is suboptimal) to itself after the fact. Instead you should verify that the solution is correct using the definition given in the question. e.g.

  • first element is the solution is the given start point,
  • last element is the given end point,
  • each point in the path is the neighbor to another.
  • and the values in the matrix corresponding to those points are non-decreasing.