iterating over last i . e ( n - 1 ) th row and connecting Node .
else if ( i == n - 1 && j <= m && j >= 1 ) { if ( j == m ) j = j - 1 j = j - 1 temp . prev = new Node ( grid [ i ] [ j ] ) temp = temp . prev }