Simple way of approaching the problem using memorization

Make two arrays :

  1. to store the max from the left side ownward
  2. to store the the min element from the right side to the left side
    Now read the question carefully and try to find the realtion between the both for each index.
Comments (0)