private int[] findPath() {
        int end = 0;
        for (int x = 0; x < width; x++) {
            if (distTo[height - 1][end] > distTo[height - 1][x]) {
                end = x;
            }
        }
        int[] path = new int[height];
        path[height - 1] = end;
        for (int i = height - 2; i >= 0; i--) {
            path[i] = pixelTo[i + 1][path[i + 1]];
        }
        pixelTo = null;
        distTo = null;
        return path;
    }