Skip to content

Interview question · Arrays

Container With Most Water

Container With Most Water is a Medium question that uses the arrays pattern. PrepKit files it under Arrays.

PrepKit lists the title and a link. The problem statement stays on the original site.

Checking your saved items

Copyright and correction requests

Source content: English

Key facts

Topic
Arrays
Pattern
arrays
Difficulty
Medium
Appears in
Grind 75
Website
leetcode.com
License
MIT License

How to use it

  1. Read the problem on the original site.
  2. Try it on your own before you look at hints or solutions.
  3. Then work through a related question with the same pattern.

About the Arrays pattern

PrepKit study notes. PrepKit editors wrote these as general advice. They are not taken from the problem or from any published solution.

What it is
Problems where the input is an indexed sequence and the work is scanning, counting or rearranging its elements. Many combine a single pass with a hash map or a running total.
How to recognize it
You get a list of numbers or items and must find a pair, a subarray or a count, or change the list in place. If the obvious double loop feels too slow, think about one pass with extra memory.
Common pitfalls
Off-by-one errors at either end, changing the array while you iterate over it, and forgetting empty, single-element or all-duplicate inputs.

Related preparation

These are PrepKit study suggestions, not employer endorsements or predictions of interview questions.

Pages that include this

Common questions

Where can I practice Container With Most Water?

Open it on leetcode.com. PrepKit links there and does not copy the problem.

What pattern does Container With Most Water use?

PrepKit files it under arrays, at Medium difficulty.

Source and license

Source and license

License:
MIT License
Author:
Yangshun Tay
Source version:
e1d28e8
Last checked against the source:
Changes:
PrepKit kept only Grind 75 question titles, difficulty, topic, and LeetCode links. The weekly schedule, durations, and ordering are not copied, and no LeetCode problem text is stored.
Visit original source
Full license and copyright notice

MIT License Copyright (c) 2017-Present Yangshun Tay Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.