Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use java to solve the problem of holding the most water containers

Shulou Source: shulou.com Published: 2022-06-01 01:01:35 10月04日 Update

This article will introduce in detail for you "how to use java to solve the problem of holding the largest number of water containers", the content steps are clear and detailed, and the details are handled properly, and the editor will update different knowledge points every day. I hope that this article "how to use java to solve the problem of holding most water containers" can give you unexpected harvest.

Given n non-negative integers A1 ai a2, each number represents a point (I, point) in the coordinates. Draw n vertical lines in the coordinates. The two endpoints of the vertical line I are (I, ai) and (I, 0), respectively. Find two of the lines so that the container composed of them and the x-axis can hold the most water.

Note: you cannot tilt the container, and the value of n is at least 2.

The vertical line in the picture represents the input array [1, 8, 6, 2, 5, 5, 4, 8, 3, 7]. In this case, the maximum value that the container can hold water (represented as the blue part) is 49.

Example:

Input: [1, 8, 6, 2, 5, 4, 8, 3, 7]

Output: 49

Parsing:

It seems more difficult to have no comments from individual feedback, so from this issue, if time permits, I will try my best to add comments. I will write comments for the first time, for fear that I will not understand them, so I will be verbose and adjust them later.

What can Java be used for? Java is mainly used in: 1. Web development; 2. Android development; 3. Client development; 4. Web page development; 5. Enterprise application development; 6. Java big data development; 7. Game development and so on.

If you can read this, the editor hopes that you will have the most profound experience from the practical level on the key issue of "how to use java to solve the problem of holding the most water containers". If you want to read more related articles, welcome to follow the industry information channel!

Tags: Development Container problem Water content Vertical Line Annotation Representative coordinates practice Application input difference proper laborious unexpected two Inner painting client client Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Information MySQL vpn Docker