You are viewing a single comment's thread. Return to all comments →
This is my javascript Solution
function stockmax(prices) { let result = 0, arr = [...prices]; arr.sort((a, b) => b - a); let index; for(let i = 0; i < arr.length; i++) { index = prices.indexOf(arr[i]); for(let j = 0; j <= index; j++) result += arr[i] - prices.shift(); if(prices.length === 0) return result; } }
Seems like cookies are disabled on this browser, please enable them to open this website
Stock Maximize
You are viewing a single comment's thread. Return to all comments →
This is my javascript Solution