Given a list of lists of Integers, find the shortest path for one list element to seek a certain element.

Example List:

(1,2,3) //index 0

(8,6,4) //index 1

(4,5,6) //index 2

…

(9,1) //index 6

(1) //index 8

…

until index 9

Find the minimum cost such that: start at index 0 (1,2,3) and find all the paths till u find a certain number (in my case, i was asked to find a path starting at index 0 until I find number 9).

so the path will look something like: [1,6,9]. Cost: [(6-1)^2 + (9-6)^2] = 25 + 9 = 34;

there can be other paths but return/print the min cost path.

I used Depth First Search to implement this.