Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Minimum Path Sum Rec

var minPathSum = function(grid) {
    const numRow = grid.length
    const numCol = grid[0].length
    const obj ={}
    
    const path =(row,col)=>{
   
        if(obj[row+ ':' +col] !== undefined){
            return obj[row+ ':' +col]
        }
        
        let right = Infinity
        let down = Infinity
        
        if(col<numCol -1){
           right= path(row,col+1)
        }
        
        if(row <numRow-1){
           down= path(row+1,col)
        }
        
        if(right === Infinity && down === Infinity){
             right = down = 0
        }
        
     const result = grid[row][col]+ Math.min(right,down);
        obj[row+ ':' +col] =result;
        return result
  
    }
    return path(0,0)
    
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: how can i debug compressed javascript in chrome 
Javascript :: dotcms json parser 
Javascript :: javascript create li element and append to ul 
Javascript :: cocos creator localstorage 
Javascript :: make react navigation to always re render 
Javascript :: execute only once on multiple clicks javascript 
Javascript :: react js date range 
Javascript :: react password check wordpress api 
Javascript :: devexpress image collection 
Javascript :: check if a number is multiple of 3 javascript 
Javascript :: add image to center in canvas 
Javascript :: click page object 
Javascript :: router.put method 
Javascript :: temporal date api 
Javascript :: random jwt secret key generator 
Javascript :: metodos de arrays javascript 
Javascript :: Get the max value from array - divi modules 
Javascript :: js cyclic motion based on cosine 
Javascript :: js draw number in range 
Javascript :: getderivedfromstate alternative 
Javascript :: How can I force a refresh in my spa website with vuejs - laravel 
Javascript :: How to escape specific JSON characters in Powershell 
Javascript :: angularjs how to get a response from a post request 
Javascript :: Angular after click add active class and remove from siblings 
Javascript :: Filtering smart-table on transformed data 
Javascript :: How to hover over data inserted from JSON 
Javascript :: assignment is to create a small website using NestJS in the backend and basic HTML CSS in the frontend 
Javascript :: C# Convert Json File to DataTable using Newtonsoft.Json DLL 
Javascript :: json query rails c 
Javascript :: function x(a) vs function x(...a) the difference 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =