My code is brute force with two optimizations:

- it starts with the lowest-valued entries and works up from there
- it ignores paths once it's visited that point from a lower start value, very likely minimizing retread

All submissions get TLE on different sets, yet run <300ms with any erring custom test case. Any ideas?

```
var longestIncreasingPath = function(m) {
var max=0
,lowestVisitedAt={}
,ijByValAsc=[]
function walk(i,j,dist,startingFrom){//,path){
var ij=[i,j]+''
if(lowestVisitedAt[ij]<startingFrom) return
lowestVisitedAt[ij]=Math.min(lowestVisitedAt[ij],startingFrom)
//will be in order: up right down left
var paths=[
m[i+1]!==undefined && m[i+1][j ]!==undefined ? m[i+1][j ] : false
,m[i ]!==undefined && m[i ][j+1]!==undefined ? m[i ][j+1] : false
,m[i-1]!==undefined && m[i-1][j ]!==undefined ? m[i-1][j ] : false
,m[i ]!==undefined && m[i ][j-1]!==undefined ? m[i ][j-1] : false
]
,recur=false
paths.forEach((x,ii)=>{
var pi= i+(ii==0? 1 : ii==2 ? -1 : 0)
,pj= j+(ii==1? 1 : ii==3 ? -1 : 0)
//only if an increase
if(x && m[pi][pj]>m[i][j]){
walk(pi,pj,dist+1,startingFrom)//,path.concat(m[pi][pj]))
recur=true
}
})
if(!recur){
//console.log(path)
max=Math.max(dist,max)
}
}
//once walker established, prioritize by starting at the lowest values
//first gather items
m.forEach((row,i)=>{
row.forEach((col,j)=>{
ijByValAsc.push({ij:[i,j],v:col})
})
})
//then sort & go
ijByValAsc
.sort((a,b)=>a.v - b.v)
.forEach(o=>{
walk(...o.ij,1,o.v)//,[o.v])
})
//track covering can minimize paths taken
return max
};
```