zoukankan      html  css  js  c++  java
  • functionclass[LeetCode]Container With Most Water

    在写这篇文章之前,xxx已经写过了几篇关于改functionclass主题的文章,想要了解的朋友可以去翻一下之前的文章

        每日一道理
    这浓浓的母爱使我深深地认识到:即使你是一只矫健的雄鹰,也永远飞不出母爱的长空;即使你是一条扬帆行驶的快船,也永远驶不出母爱的长河!在人生的路上不管我们已走过多远,还要走多远,我们都要经过母亲精心营造的那座桥!
    class Solution {
    //Find two lines, which together with x-axis forms a container, such that the container contains the most water.
    //if do not together with x-axis forms a container, 
    //and together with other lines then it will be more difficult to find out an effective solution
    public:
    	int maxArea(vector<int> &height) {
    		// Start typing your C/C++ solution below
    		// DO NOT write int main() function
    		int l = 0;
    		int r = height.size()-1;
    		int ans = 0;
    		while (l < r)
    		{
    			int tmp = min(height[r], height[l])*(r-l);
    			if(tmp > ans) ans = tmp;
    			if(height[r] < height[l])
    				r--;
    			else l++;
    		}
    		return ans;
    	}
    };

    文章结束给大家分享下程序员的一些笑话语录: 一个合格的程序员是不会写出 诸如 “摧毁地球” 这样的程序的,他们会写一个函数叫 “摧毁行星”而把地球当一个参数传进去。

    --------------------------------- 原创文章 By
    function和class
    ---------------------------------

  • 相关阅读:
    js中父窗口获得模态窗口的返回值
    Jquery获取控件值实例(转载)
    各种类库网址学习
    IIS启动网站时, 提示: “另一个程序正在使用此文件,进程无法访问”
    查看端口占用情况
    顽固的换行问题
    mac上共享android手机屏幕软件
    关于软键盘弹出的问题
    mac搭建android studio开发环境
    C语言位域和大小端
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3105096.html
Copyright © 2011-2022 走看看