two pointers

https://www.geeksforgeeks.org/container-with-most-water/

Approach :

  • This implies that if there was a better solution possible, it will definitely have the Height greater than min(a1, aN).
     Base * Height > (N-1) * min(a_1, a_N)
  • We know that, Base min(a1, aN)
    This means that we can discard min(a1, aN) from our set and look to solve this problem again from the start.
  • If a1 < aN, then the problem reduces to solving the same thing for a2, aN.
  • Else, it reduces to solving the same thing for a1, aN-1

 

 

 

posted @ 2019-02-02 17:12  ChuckLu  阅读(158)  评论(0编辑  收藏  举报