Skip to content

Commit

Permalink
Create Solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
Mansi8874 authored Jan 27, 2024
1 parent 35eb903 commit b24309b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Day-21/q2 : Container With Most Water/Solutions
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution {
public int maxArea(int[] height) {
int area=0;
int i=0;
int j=height.length-1;
while(i<j){
int x=(j-i)*(Math.min(height[i],height[j]));
if(area<x){
area=x;
}
if(height[i]<height[j]){
i++;
}else{
j--;
}
}
return area;
}
}

0 comments on commit b24309b

Please sign in to comment.