Microsoft Engage 2025 | Two Pointers Logic | Container With Most Water

Microsoft · Question · Posted Jun 2026

Question: Container With Most Water Problem Statement You are given an integer array heights of length N. There are N vertical lines drawn such that the two endpoints of the i-th line are (i, 0) and (i, heights[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. Input Format The first line contains T - the number of test cases. ...

The full answer & interview discussion are available to premium members.

Log in Create a free account