WaterContainerSpace

Run Settings
LanguageJavaScript
Language Version
Run Command
const container = function(input_array) { let highestArea = 0; let firstNode = 0; let lastNode = input_array.length-1; if(input_array.length <= 1) { return 0; } for (let i = 0; i < input_array.length; i++) { let localArea = input_array[firstNode] > input_array[lastNode] ? input_array[lastNode] * (lastNode - firstNode) : input_array[firstNode] * (lastNode - firstNode); highestArea = localArea > highestArea ? localArea : highestArea; if (firstNode < input_array.length - 1 && lastNode > 1) { console.log(input_array[firstNode]); if (input_array[firstNode] <= input_array[lastNode]) { firstNode++; } else { lastNode--; } } } console.log(highestArea); } container([1,7,2,0,1,3]);
Editor Settings
Theme
Key bindings
Full width
Lines