Bird
0
0
DSA Cprogramming~10 mins

Container With Most Water in DSA C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare the function that calculates the maximum water container area.

DSA C
int maxArea(int* height, int heightSize) {
    int [1] = 0;
    return 0;
}
Drag options to blanks, or click blank then click option'
Amax_area
BmaxWater
Carea
Dresult
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that is not descriptive or unrelated to the problem.
2fill in blank
medium

Complete the code to initialize the left pointer at the start of the array.

DSA C
int left = [1];
Drag options to blanks, or click blank then click option'
A0
B1
C-1
DheightSize
Attempts:
3 left
💡 Hint
Common Mistakes
Starting the left pointer at 1 or a negative index.
3fill in blank
hard

Fix the error in the while loop condition to correctly iterate while left is less than right.

DSA C
while (left [1] right) {
    // loop body
}
Drag options to blanks, or click blank then click option'
A>
B<
C>=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using >= or > which causes the loop to skip or run incorrectly.
4fill in blank
hard

Fill both blanks to calculate the current area and update max_area if needed.

DSA C
int width = right - left;
int height_min = height[left] < height[right] ? height[left] : height[right];
int current_area = width * [1];
if (current_area [2] max_area) {
    max_area = current_area;
}
Drag options to blanks, or click blank then click option'
Aheight_min
Bheight[left]
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong height for area calculation or wrong comparison operator.
5fill in blank
hard

Fill all three blanks to move the pointers correctly based on the heights.

DSA C
if (height[left] < height[right]) {
    [1]++;
} else {
    [2]--;
}

// Return the maximum area found
return [3];
Drag options to blanks, or click blank then click option'
Aleft
Bright
Cmax_area
Dheight
Attempts:
3 left
💡 Hint
Common Mistakes
Moving the wrong pointer or returning the wrong variable.