Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions container-with-most-water/s0ooo0k.java
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 문제는 제가 풀지 않았지만 어떤 문제였는지 코드만 봐도 알 거 같았어요. 목적을 한 번에 파악할 수 있어서 좋았습니다.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 리뷰 감사합니다!

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution {
public int maxArea(int[] height) {
int left=0;
int right=height.length-1;
int max=0;

while(left<right) {
int water = (right-left) * Math.min(height[left], height[right]);
max = Math.max(max, water);

if(height[left]<height[right]) {
left++;
} else {
right--;
}
}
return max;
}
}


26 changes: 26 additions & 0 deletions valid-parentheses/s0ooo0k.java
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

조건에 맞는지 확인을 하고 pop을 하는 순서네요! Deque 타입은 처음 봤어요. 언어마다 다르게 검증해야 하는 걸 알 수 있어서 좋았습니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Solution {
public boolean isValid(String s) {
Deque<Character> stack = new ArrayDeque<>();

for(char c : s.toCharArray()) {
if(c == '(' || c=='{' || c=='[') {
stack.push(c);
}
if(c == ')') {
if(stack.isEmpty() || stack.peek() != '(') return false;
stack.pop();
}
if(c == '}') {
if(stack.isEmpty() || stack.peek() != '{') return false;
stack.pop();
}
if(c == ']') {
if(stack.isEmpty() || stack.peek() != '[') return false;
stack.pop();
}
}
return stack.isEmpty();
}
}