We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
idea is to trverse the array from back and get the difference with local maximum , so profit will be the sum of all differences with local maximum. it should be sloved in o(N).
Stock Maximize
You are viewing a single comment's thread. Return to all comments →
idea is to trverse the array from back and get the difference with local maximum , so profit will be the sum of all differences with local maximum. it should be sloved in o(N).