Stock Maximize Discussions | Algorithms | HackerRank
  • + 6 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).