Container With Most Water LeetCode Programming Solutions | LeetCode Problem Solutions in C++, Java, & Python [💯Correct]

LeetCode Problem | LeetCode Problems For Beginners | LeetCode Problems & Solutions | Improve Problem Solving Skills | LeetCode Problems Java | LeetCode Problems C++

Hello Programmers/Coders, Today we are going to share solutions to the Programming problems of LeetCode Solutions in C++, Java, & Python. At Each Problem with Successful submission with all Test Cases Passed, you will get a score or marks and LeetCode Coins. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.

In this post, you will find the solution for the Container With Most Water in C++, Java & Python-LeetCode problem. We are providing the correct and tested solutions to coding problems present on LeetCode. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

About LeetCode

LeetCode is one of the most well-known online judge platforms to help you enhance your skills, expand your knowledge and prepare for technical interviews. 

LeetCode is for software engineers who are looking to practice technical questions and advance their skills. Mastering the questions in each level on LeetCode is a good way to prepare for technical interviews and keep your skills sharp. They also have a repository of solutions with the reasoning behind each step.

LeetCode has over 1,900 questions for you to practice, covering many different programming concepts. Every coding problem has a classification of either EasyMedium, or Hard.

LeetCode problems focus on algorithms and data structures. Here is some topic you can find problems on LeetCode:

  • Mathematics/Basic Logical Based Questions
  • Arrays
  • Strings
  • Hash Table
  • Dynamic Programming
  • Stack & Queue
  • Trees & Graphs
  • Greedy Algorithms
  • Breadth-First Search
  • Depth-First Search
  • Sorting & Searching
  • BST (Binary Search Tree)
  • Database
  • Linked List
  • Recursion, etc.

Leetcode has a huge number of test cases and questions from interviews too like Google, Amazon, Microsoft, Facebook, Adobe, Oracle, Linkedin, Goldman Sachs, etc. LeetCode helps you in getting a job in Top MNCs. To crack FAANG Companies, LeetCode problems can help you in building your logic.

Link for the ProblemContainer With Most Water– LeetCode Problem

Container With Most Water– LeetCode Problem


You are given an integer array height of length n. There are n vertical lines are drawn such that the two endpoints of the ith line is (i, 0) and (i, height[i]).

Find two lines that together with the x-axis form a container, such that the container contains the most water.

Return the maximum amount of water a container can store.

Notice that you may not slant the container.

Example 1:

question 11
Input: height = [1,8,6,2,5,4,8,3,7]
Output: 49
Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.

Example 2:

Input: height = [1,1]
Output: 1


  • n == height.length
  • 2 <= n <= 105
  • 0 <= height[i] <= 104
Container With Most Water– LeetCode Solutions
class Solution {
  int maxArea(vector<int>& height) {
    int ans = 0;
    int l = 0;
    int r = height.size() - 1;

    while (l < r) {
      const int minHeight = min(height[l], height[r]);
      ans = max(ans, minHeight * (r - l));
      if (height[l] < height[r])

    return ans;
class Solution {
  public int maxArea(int[] height) {
    int ans = 0;
    int l = 0;
    int r = height.length - 1;

    while (l < r) {
      final int minHeight = Math.min(height[l], height[r]);
      ans = Math.max(ans, minHeight * (r - l));
      if (height[l] < height[r])

    return ans;
class Solution:
  def maxArea(self, height: List[int]) -> int:
    ans = 0
    l = 0
    r = len(height) - 1

    while l < r:
      minHeight = min(height[l], height[r])
      ans = max(ans, minHeight * (r - l))
      if height[l] < height[r]:
        l += 1
        r -= 1

    return ans

1,493 thoughts on “Container With Most Water LeetCode Programming Solutions | LeetCode Problem Solutions in C++, Java, & Python [💯Correct]”

  1. can i purchase mobic for sale [url=]where to buy cheap mobic without rx[/url] how can i get generic mobic without dr prescription

  2. buy prescription drugs from india [url=]indian pharmacy paypal[/url] buy medicines online in india

  3. pharmacy website india [url=]cheapest online pharmacy india[/url] cheapest online pharmacy india

  4. To announce true to life rumour, dog these tips:

    Look representing credible sources: It’s material to secure that the newscast source you are reading is reputable and unbiased. Some examples of reputable sources subsume BBC, Reuters, and The Modish York Times. Read multiple sources to get a well-rounded view of a discriminating info event. This can better you listen to a more complete paint and keep bias. Be aware of the angle the article is coming from, as set reputable hearsay sources can be dressed bias. Fact-check the information with another fountain-head if a communication article seems too lurid or unbelievable. Forever fetch persuaded you are reading a advised article, as news can transmute quickly.

    Nearby following these tips, you can evolve into a more aware of scandal reader and better apprehend the world around you.

  5. Try your luck at the slot machine and earn free chips. Spin each day for even more chips! What I like about Poker Face is that it’s not single-mindedly focused on the game itself. It lets you chat before, during and after each game, with all five players appearing onscreen in small video windows. And that means you can look your opponents in the eyes and play rounds almost as if they were in the same room. Which is something we all really need right now. Each player is dealt two cards (hole cards). Look at your cards and decide if you want to place a bet or opt out (fold). Once all bets are placed, the dealer deals the flop: three face-up cards in the middle. Another round of betting follows, during which players can check or raise the bet. A fourth face-up card is added (the turn) and another betting round follows. After that, the fifth and last community card (the river) is dealt and the showdown can begin.
    Roulette Casino Chips Interestingly, roulette is also a game packed full of interesting rules, bets and side bets. We’ll explore the latter below, while asking how these can impact on the game and your chances of winning. To play Roulette, place a chip on a number or a combination of numbers and wait for the Dealer to spin the ball. You can also bet on red or black, odd or even, dozens or high and low numbers. European roulette, just like French roulette, provides better odds than American roulette. The wheel only has a single zero pocket, making European roulette easier to win than its American counterpart. Roulette is an intriguing game that is played throughout the world. The large payoffs that are possible for small wagers stimulate the interest of the expert as well as the novice player, playing Roulette in Vegas.

  6. Totally! Conclusion info portals in the UK can be awesome, but there are tons resources accessible to cure you think the unexcelled in unison because you. As I mentioned formerly, conducting an online search with a view “UK news websites” or “British story portals” is a enormous starting point. Not but purposefulness this hand out you a thorough shopping list of report websites, but it intention also provender you with a punter savvy comprehension or of the common news prospect in the UK.
    Once you have a itemize of imminent news portals, it’s powerful to evaluate each sole to choose which best suits your preferences. As an example, BBC Advice is known in place of its disinterested reporting of information stories, while The Custodian is known quest of its in-depth analysis of partisan and popular issues. The Independent is known representing its investigative journalism, while The Times is known in search its work and funds coverage. By concession these differences, you can choose the rumour portal that caters to your interests and provides you with the rumour you have a yen for to read.
    Additionally, it’s usefulness looking at close by scuttlebutt portals representing specific regions within the UK. These portals provide coverage of events and good copy stories that are applicable to the area, which can be exceptionally cooperative if you’re looking to safeguard up with events in your neighbourhood pub community. In behalf of event, shire good copy portals in London classify the Evening Standard and the Londonist, while Manchester Evening Hearsay and Liverpool Reflection are in demand in the North West.
    Overall, there are diverse tidings portals at one’s fingertips in the UK, and it’s high-level to do your research to unearth the united that suits your needs. At near evaluating the unconventional low-down portals based on their coverage, dash, and essay standpoint, you can judge the one that provides you with the most apposite and engrossing news stories. Meet luck with your search, and I ambition this tidings helps you discover the just right expos‚ portal since you!

  7. Do you mind if I quote a few of your articles as long
    as I provide credit and sources back to your weblog?

    My blog site is in the very same area of interest as yours and my users would truly benefit from some of the information you present here.

    Please let me know if this okay with you. Thanks a lot!

  8. can you buy zithromax over the counter in australia [url=]buy Z-Pak online[/url] generic zithromax azithromycin

  9. Dopo aver accennato al bonus Gioco Digitale, non resta che vederne i passaggi necessari per ottenerlo. Come visto precedentemente, aderire all’iniziativa di benvenuto dell’operatore è decisamente semplice. In primo luogo è necessario effettuare la registrazione sul sito. Dunque requisito fondamentale è non aver mai creato un account su Gioco Digitale. Dopo di ché basta effettuare un deposito qualificante e convalidare il conto di gioco. Essenzialmente il bonus benvenuto si articola in due parti. Oltre a questa indispensabile certificazione, Gioco Digitale può vantarsi di collaborazioni importanti che sono finalizzate ad erogare solo un servizio di gioco responsabile e certificato. Ogni casinò online deve mettere in atto pratiche che consentano al giocatore di tenere sotto controllo i suoi comportamenti. Gioco Digitale si avvale della consulenza di EGBA (European Gaming & Betting Association) e ESSA (European Sport Security Association). Le sue attività finalizzate al gioco responsabile sono sostenute e coadiuvate dalla Division on Addiction, Cambridge Health Alliance della Harvard Medical School.
    In primis, si consiglia di scegliere le slot machine che di recente hanno raggiunto una percentuale media di restituzione (RTP) più alta. Diciamo questo perché sono quelle che pagano le vincite più frequentemente e garantiscono una velocità di sblocco del bonus senza deposito sicuramente maggiore. Ricordiamo che i valori dei payout dei casinò games si possono facilmente individuare prendendo visione della tabella dei payout che ogni concessionario per legge è obbligato a pubblicare, al fine di garantire massima trasparenza del proprio operato. Miglior gioco slot machine – I bonus sono un’ottima opzione messa a disposizione dai migliori casino EU per permettere ai giocatori di registrarsi su un sito e beneficiare subito di una promozione, possono dare un bonus in denaro fino a una certa percentuale del tuo deposito iniziale. La funzione terminerà e non otterrai una vittoria se il tuo petto affonda durante il primo round, ne Apple che Andrid.

  10. An initiative we launched with the goal to create a global self-exclusion system, which will allow vulnerable players to block their access to all online gambling opportunities. We will keep the main focus on Rolletto’s casino section in this particular review. OnyxioN B.V. is the company that owns and runs the casino. They currently obtain a Curacao gaming license. While it is not the strongest license out there, combined with several certificates that confirm the fairness of the games and the protection of player’s personal and financial data, it makes us feel safe while enjoying the casino’s outstanding array of games. Bonus Codes for European Roulette European Roulette free spins are not part of the bonus features. European Roulette no deposit play is no longer a shallow promise! With us you will without a doubt not only get to know about the slot game and its mechanisms but also to gain some hot free spins! All the time you will be able to try out the slot game without having to make any prior money deposit.
    Casino Splendido Online Games: As said before, Casino Splendido has a remarkable (so remarkable, I’m mentioning it twice) 350+ games within its virtual walls. That is almost a year’s worth—and at the rate they are being added each month, it won’t be long until you can play a different game each day for over a year. Should players at Casino Splendido experience any issues, there is an excellent Support team at their service to provide in-depth information and assistance around the clock. Players, who register at the website should prepare themselves for some royal treatment, not to mention their bankrolls can be boosted by the numerous splendid bonuses and promotional offers, available at Casino Splendido. Of course, in order to walk away with a massive prize, players are expected to fund their accounts and play for real money. In this respect, there is hardly any room for improvements as Casino Splendido covers a vast range of the safest and most convenient payment solutions.

  11. Powered by Squarespace The best places to get eyelash extensions are those that make the experience as comfortable as possible. You’ll pay more in spas or salons where you are offered beverages and cushy places to rest as the lashes are placed. Salons that are willing to do patch tests, free consultations, and that offer aftercare products can charge more than someone who applies lash extensions out of her home. You might have to pay more at cleaner more modern places, but this is worth the cost as it reduces the risk of complications and allows you to rest during your application, knowing that the service is catered to your needs. We include a FREE 10-15 minute Lash Consultation with your Lash Stylist with all new full sets. We assess the length of your natural lashes to determine the optimum lash extension length, width, weight and style. Additionally we discuss lash health, aftercare and refill cadence and policy. You also have the option to come in for an eyelash extension consultation ahead of your appointment instead at no cost. We’re here to help you have the eyelash extensions of your dreams and a consultation can really help you achieve your beauty goals.
    You will never be more enthusiastic about your makeup artist job than while buying your first makeup kit. Anyway, it is essential that you won’t get too excited and buy the wrong stuff. Investing in products that are low quality or don’t fit your domain (as there are makeup artists for photo shootings, for movies, for TV, for events, etc.) is pointless. One of my rules of thumb — something I bring up in my book Be Your Own Makeup Artist — is that less is more. You definitely don’t need to wear tons of makeup to wear makeup. And guess what? Wearing a lot of makeup won’t make you feel better about yourself. Sometimes it might even make you feel worse. In the end, it’s all about wearing the right makeup in the right amount for you. As a visual learner, I can better process colour combinations for my makeup looks when I can see them so I swatch the colours I am going to use on my hands. It is a very easy step but makes all the difference to me because I used to just keep applying the products and removing them if they did not work well together but it would waste time and disrupt the parts of the look that I already completed.

  12. Cortexi is a completely natural product that promotes healthy hearing, improves memory, and sharpens mental clarity. Cortexi hearing support formula is a combination of high-quality natural components that work together to offer you with a variety of health advantages, particularly for persons in their middle and late years. Cortex not only improves hearing but also decreases inflammation, eliminates brain fog, and gives natural memory protection.

  13. FitSpresso stands out as a remarkable dietary supplement designed to facilitate effective weight loss. Its unique blend incorporates a selection of natural elements including green tea extract, milk thistle, and other components with presumed weight loss benefits.

  14. Neotonics is an essential probiotic supplement that works to support the microbiome in the gut and also works as an anti-aging formula. The formula targets the cause of the aging of the skin.

  15. EyeFortin is a natural vision support formula crafted with a blend of plant-based compounds and essential minerals. It aims to enhance vision clarity, focus, and moisture balance.

  16. GlucoBerry is one of the biggest all-natural dietary and biggest scientific breakthrough formulas ever in the health industry today. This is all because of its amazing high-quality cutting-edge formula that helps treat high blood sugar levels very naturally and effectively.

  17. InchaGrow is an advanced male enhancement supplement. Discover the natural way to boost your sexual health. Increase desire, improve erections, and experience more intense orgasms.

  18. Cortexi is an effective hearing health support formula that has gained positive user feedback for its ability to improve hearing ability and memory. This supplement contains natural ingredients and has undergone evaluation to ensure its efficacy and safety. Manufactured in an FDA-registered and GMP-certified facility, Cortexi promotes healthy hearing, enhances mental acuity, and sharpens memory.

  19. Sight Care is a daily supplement proven in clinical trials and conclusive science to improve vision by nourishing the body from within. The Sight Care formula claims to reverse issues in eyesight, and every ingredient is completely natural.

  20. I’ve been following discussions on this topic for a while, but your post was a breath of fresh air. It’s evident you’ve done your homework, and your insights are spot on. It sparked a few ideas in my mind. Mind if I share a counterpoint for the sake of discussion?