码迷,mamicode.com
首页 > 其他好文 > 详细

two pointers

时间:2019-02-02 19:19:31      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:contain   geeks   with   title   nta   ini   min   lin   ssi   

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).
    技术图片
  • 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

 

 

 

two pointers

标签:contain   geeks   with   title   nta   ini   min   lin   ssi   

原文地址:https://www.cnblogs.com/chucklu/p/10348787.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!