-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Bug Report for https://neetcode.io/problems/max-water-container
Accessing out of bound answer accepted only as test case, shows different Your Output:
With following implementation:
class Solution {
public:
int maxArea(vector<int>& heights) {
if (heights.size() <= 1) return 0;
int i = 0, j = heights.size(), max_vol = 0; // accessing out of bound j should be size - 1
while (i < j) {
int curr = min(heights[i], heights[j]) * (j - i);
max_vol = max(curr, max_vol);
if (heights[i] < heights[j]) {
i++;
} else {
j--;
}
}
return max_vol;
}
};
The input case: height=[1,7,2,5,12,3,500,500,7,8,4,7,3,6]
: submitting shows incorrect answer Your Output: 744
, while using input as test case is accepted Your Output: 500
.


PS: Much appreciated for your website.
Metadata
Metadata
Assignees
Labels
No labels