diff --git a/src/week01/Yoepee/PG_120802.java b/src/week01/Yoepee/PG_120802.java deleted file mode 100644 index 04b35db..0000000 --- a/src/week01/Yoepee/PG_120802.java +++ /dev/null @@ -1,4 +0,0 @@ -package week01.Yoepee; - -public class PG_120802 { -} diff --git a/src/week01/Yoepee/PG_60058.java b/src/week01/Yoepee/PG_60058.java new file mode 100644 index 0000000..475236d --- /dev/null +++ b/src/week01/Yoepee/PG_60058.java @@ -0,0 +1,82 @@ +package week01.Yoepee; + +// 괄호 변환 +public class PG_60058 { + static class Solution { + public String solution(String p) { + String answer = ""; + // 빈 문자열인 경우, 빈 문자열 반환 + if (p.length() == 0) return ""; + // string의 길이가 2일 경우 올바른 괄호 문자열은 () 밖에 없으므로 () 반환 + else if (p.length() == 2) return "()"; + + // u가 끝나는 index + int start = 0; + // 괄호가 제대로 닫혔는지 확인하는 변수 + int count = 0; + // 균형잡힌 괄호 문자열 u가 올바른 괄호 문자열인지 확인하는 변수 + boolean isRight = true; + + // 균형잡힌 문자열 p를 u와 v로 나누는 로직 + for (int i = 0; i