Skip to content

Commit 4ee769a

Browse files
authored
Merge pull request #1874 from s0ooo0k/main
[s0ooo0k] WEE6 Solutions
2 parents c312c3c + 02dab0e commit 4ee769a

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public int maxArea(int[] height) {
3+
int left=0;
4+
int right=height.length-1;
5+
int max=0;
6+
7+
while(left<right) {
8+
int water = (right-left) * Math.min(height[left], height[right]);
9+
max = Math.max(max, water);
10+
11+
if(height[left]<height[right]) {
12+
left++;
13+
} else {
14+
right--;
15+
}
16+
}
17+
return max;
18+
}
19+
}
20+
21+

valid-parentheses/s0ooo0k.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Solution {
2+
public boolean isValid(String s) {
3+
Deque<Character> stack = new ArrayDeque<>();
4+
5+
for(char c : s.toCharArray()) {
6+
if(c == '(' || c=='{' || c=='[') {
7+
stack.push(c);
8+
}
9+
if(c == ')') {
10+
if(stack.isEmpty() || stack.peek() != '(') return false;
11+
stack.pop();
12+
}
13+
if(c == '}') {
14+
if(stack.isEmpty() || stack.peek() != '{') return false;
15+
stack.pop();
16+
}
17+
if(c == ']') {
18+
if(stack.isEmpty() || stack.peek() != '[') return false;
19+
stack.pop();
20+
}
21+
}
22+
return stack.isEmpty();
23+
}
24+
}
25+
26+

0 commit comments

Comments
 (0)