Untitled

mail@pastecode.io avatar
unknown
plain_text
11 days ago
413 B
3
Indexable
Never
var maxArea = function(height) {

    let i = 0;
    let j = height.length - 1;
    let map = new Map();

    while(i < j){

        
        map.set(Math.min(height[i], height[j]) * (j - i))

        if(height[i] < height[j]){
            i++;
        }
        else{
            j--;
        }

    }
    
    map = Array.from(map.keys()).sort((a,b) => b[0] - a[0]);

    console.log(map)
    
    return map
};
Leave a Comment